对 'abs' 的调用不明确
Call to 'abs' is ambiguous
此错误专门发生在这一行
nRandom = abs(arc4random());
完整的方法是
void PlayLayer::update(float dt)
{
if ( bPause || bBuy )
{
return;
}
nRandom = abs(arc4random());
labNet->setVisible(false);
labNetNum->setVisible(false);
if ( mType == game_bet )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
bStand = false;
bDouble = false;
}
if ( mType == game_deal )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
bStand = false;
}
if ( mType == game_play )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
// if ( bStand && !bDouble)
// {
// this->createDealerCard();
// this->addedDealCardEvalution();
// }
}
if ( mType == game_end )
{
labNet->setVisible(true);
labNetNum->setVisible(true);
if ( mTPlay == play_lose )
{
labNetNum->setString(__String::createWithFormat("-$%d", nBet)->getCString());
}
if ( mTPlay == play_match )
{
labNetNum->setString("+0");
}
if ( mTPlay == play_win )
{
labNetNum->setString(__String::createWithFormat("+$%d", nBet)->getCString());
}
bNoticeClickEnable = false;
labLeft->setString("");
labLeft->setOpacity(120);
labCenter->setString("SHUFFLE");
labCenter->setOpacity(255);
labRight->setString("PLAY");
labRight->setOpacity(255);
if ( g_nYourCoin > 200 )
{
nTempMaxBet = 200;
}
else
{
nTempMaxBet = g_nYourCoin;
}
bStand = false;
}
this->visibleItemCoins();
this->drawScores();
}
arc4random()
的签名:
uint32_t arc4random(void);
abs()
的签名:
int abs(int) __pure2;
然后当我尝试你的东西时:
abs(arc4random());
XCode 告诉我这个:
Taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned
int') has no effect
这引出了一个问题,为什么你需要 un 有符号整数的绝对值?
假设您没有使用负数,那么您可以将随机值直接分配给您的变量。如果可能的话,我会建议将它转换为 uint32_t
以外的东西。在不知道 nRandom
是什么的情况下,我无法告诉您将其转换为什么。
此错误专门发生在这一行
nRandom = abs(arc4random());
完整的方法是
void PlayLayer::update(float dt)
{
if ( bPause || bBuy )
{
return;
}
nRandom = abs(arc4random());
labNet->setVisible(false);
labNetNum->setVisible(false);
if ( mType == game_bet )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
bStand = false;
bDouble = false;
}
if ( mType == game_deal )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
bStand = false;
}
if ( mType == game_play )
{
labNotice->setVisible(itemNotice->isVisible());
labLeft->setOpacity(itemLeft->getOpacity());
labCenter->setOpacity(itemCenter->getOpacity());
labRight->setOpacity(itemRight->getOpacity());
// if ( bStand && !bDouble)
// {
// this->createDealerCard();
// this->addedDealCardEvalution();
// }
}
if ( mType == game_end )
{
labNet->setVisible(true);
labNetNum->setVisible(true);
if ( mTPlay == play_lose )
{
labNetNum->setString(__String::createWithFormat("-$%d", nBet)->getCString());
}
if ( mTPlay == play_match )
{
labNetNum->setString("+0");
}
if ( mTPlay == play_win )
{
labNetNum->setString(__String::createWithFormat("+$%d", nBet)->getCString());
}
bNoticeClickEnable = false;
labLeft->setString("");
labLeft->setOpacity(120);
labCenter->setString("SHUFFLE");
labCenter->setOpacity(255);
labRight->setString("PLAY");
labRight->setOpacity(255);
if ( g_nYourCoin > 200 )
{
nTempMaxBet = 200;
}
else
{
nTempMaxBet = g_nYourCoin;
}
bStand = false;
}
this->visibleItemCoins();
this->drawScores();
}
arc4random()
的签名:
uint32_t arc4random(void);
abs()
的签名:
int abs(int) __pure2;
然后当我尝试你的东西时:
abs(arc4random());
XCode 告诉我这个:
Taking the absolute value of unsigned type 'uint32_t' (aka 'unsigned int') has no effect
这引出了一个问题,为什么你需要 un 有符号整数的绝对值?
假设您没有使用负数,那么您可以将随机值直接分配给您的变量。如果可能的话,我会建议将它转换为 uint32_t
以外的东西。在不知道 nRandom
是什么的情况下,我无法告诉您将其转换为什么。