【发布时间】:2013-04-05 06:42:11
【问题描述】:
我正在使用 cocos2d 制作游戏。通过使用以下代码,我添加了一个动画。如何发送CCSprite 参考?
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]];
}
如何在animate_sprite方法中获取精灵引用?
【问题讨论】:
-
让 sprite 成为 ivar,或者给它一个标签并使用 getchildbytag
标签: iphone objective-c xcode cocos2d-iphone ccsprite