cocos2d中多个CCSprite循环播放CCMoveBy动画的问题
想做一个持续运动的效果。采用
NSTimer
来计时触发动画:
```objective-c [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(melonPush) userInfo:nil repeats:YES];
`melonPush`方法是这么写的:
```objective-c
- (void)melonPush
{
CCSprite *walnut = [walnutSprites lastObject];
if (walnut.position.x >= 470) {
return;
}
CCMoveBy *push = [CCMoveBy actionWithDuration:.1f position:ccp(10, 0)];
[melonSprite runAction:push];
for (int i = [walnutSprites count] - 1; i >= 0; i--) {
CCSprite *nut = [walnutSprites objectAtIndex:i];
[nut runAction:push];
}
}
但是在运行的时候,只有最后一个应用
runAction
的对象才有动画,其它的对象都不动。这是怎么回事?
PPPoE
11 years, 2 months ago