Hi!
SOMEONE PLZPLZPLzPLZ tell me why this happens:
I schedule this tick function where i should get a random object. But it is always in the same order, why and how can i actually make it random…
See the image in the bottom to see the order…
Thanks for the quick reply!
the for the Utils::getGems() is:
CCArray* Utils::getGems()
{
CCArray* ary = CCArray::create();
for (int i = 1; i <= 6; i++) {
CCString* fileNum = CCString::createWithFormat(“gemstone%d.png”, i);
ary->addObject(fileNum);
}
return ary;
}
How xD:)
just please give me a little example please…
I’ve tried this: gem->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache->spriteFrameByName((CCString)Utils::getGems()->randomObject)));
but that does not work!
it just gives the same result!
U R MY GOD IF U CAN HELP!
void Game::showMole()
{
srand(time(NULL));
CCString string = (CCString)Utils::getGems()->randomObject();
Gem* gem = Gem::create();
gem->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(string->getCString()));
gem->setPosition(ccp(100*timesX, 400));
this->addChild(gem);
gemsOnScreen->addObject(gem);
timesX++;
}
I DID ALL WHAT U SAID:(
Can u plzplzplz TRY to figure whats wrong, it does still just give the same order, now it is just my purple that comes up…
And I REALLY APPRECIATE YOUR HELP AND TIME!