【发布时间】:2014-01-03 14:06:37
【问题描述】:
我有一些精灵表,我必须永远制作动画,我想将它添加为CCLayer
到我的场景。
稍后,我必须在屏幕上移动整个动画精灵。
因此,例如,我有一些狗走路的动画,来自精灵表,这个动画永远在运行。比我希望能够在制作动画时在屏幕上移动这条狗。
最好的方法是什么? (或正确的方式)
这就是我动画帧的方式:
CCSprite *boom;
boom = [CCSprite spriteWithSpriteFrameName:[NSString stringWithFormat:@"%@_00000.png",file]];
boom.position=touch;
[self addChild:boom];
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 0; i < 5; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:
@"%@_0000%i.png",file,i]];
[animFrames addObject:frame];
}
CCAnimation* boxAnimation = [CCAnimation animationWithSpriteFrames:animFrames delay:0.075f];
CCAnimate * boxAction = [CCAnimate actionWithAnimation:boxAnimation];
CCAction *call=[CCCallBlock actionWithBlock:^{[self removeFromParentAndCleanup:YES];}];
CCAction * sequence=[CCSequence actions:boxAction,[CCHide action],call,nil];
[boom runAction:sequence];
return self;
你会如何移动这整个东西?
【问题讨论】:
标签: cocos2d-iphone