I am making a game using cocos2d. By using the following code,I have added an animation.How do I send the CCSprite
reference?
if(sprite != monkey)
{
[self scheduleOnce:@selector(animate_sprite:) delay:0.1f];
}
-(void)animate_sprite:(ccTime) dt
{
id s2 = [CCScaleTo actionWithDuration:0.5 scaleX:2.0 scaleY:2.0];
id fun = [CCCallFuncN actionWithTarget:self selector:@selector(spriteDone:)];
[sprite runAction:[CCSequence actions:s2,fun,nil]];
}
How to get the sprite reference in animate_sprite
method?
You can use performSelector:withObject:afterDelay
this will do the same thing.
if(sprite != monkey)
{
[self performSelector:@selector(animate_sprite:) withObject:sprite afterDelay:0.1f];
}
-(void)animate_sprite:(CCSprite *)sprite
{
id s2 = [CCScaleTo actionWithDuration:0.5 scaleX:2.0 scaleY:2.0];
id fun = [CCCallFuncN actionWithTarget:self selector:@selector(spriteDone:)];
[sprite runAction:[CCSequence actions:s2,fun,nil]];
}
So just edit your method to use the sprite and not the ccTime object since you are not using it at all.