Hey Guys,
i just happened to need do a simple program but i got this problem,
basically what i need to do is switching some Sprites, from a list of them.
in the init function i have this,
//list<CCSprite*> images. in the header which add the images.
//list<CCSprite*>::iterator imagetator; // obvious
for(int n = 0;n<30;n**,IMAGE_AMOUNT**)
{
CCSprite sprite = new CCSprite;
sprite~~>initWithFile;
sprite~~>setPosition;
sprite~~>setIsVisible;
images.push_back;
this~~>addChild;
CCSpritesprite2 = CCSprite::spriteWithFile(“my.png”);
sprite2~~>setPosition;
sprite2~~>setIsVisible(true);
images.push_back(sprite2);
this~~>addChild;
}
speed = 20;
decrease = 0.03;
imagetator = images.begin;
this~~>schedule(schedule_selector(HelloWorld::change),0.15);
and this is the function that is supppose to do the magic, and is is supose to go forward the list and
putting each sprite in the front. But when is executes for a little time, it goes crazy and start leaking,
slow down the device. I haven’t realize what’s up with this behabior
void HelloWorld::change()
{
if(isrolling)
{
if(speed > 0)
{
if(imagetator == images.end()) imagetator = images.begin();
previous = *imagetator;
(*previous).setIsVisible(false);
if(imagetator != images.end())
{
(**imagetator).setPosition(ccp(CCDirector::sharedDirector()>getWinSize.width/3,CCDirector::sharedDirector>getWinSize.height/2));
.setIsVisible;
imagetator++;
}
else imagetator = images.begin;
speed~~= decrease;
}
else if
{
// clean;
// this~~>SelectorProtocol::selectorProtocolRelease();
}
}
}