我正在尝试在sprite animate中创建一个cocos2D。我相信已经设置了动画,但是如何在屏幕上绘制animating sprite?这是我所拥有的:

id anim = [[[CCAnimation alloc] initWithName:@"char_walking" delay:1/12.0] autorelease];

[anim addFrame:@"run2.png"];
[anim addFrame:@"run1.png"];
[anim addFrame:@"run3.png"];
[anim addFrame:@"run4.png"];
[anim addFrame:@"run3.png"];
[anim addFrame:@"run1.png"];

id myAction = [CCAnimate actionWithAnimation:anim];
id repeating = [CCRepeatForever actionWithAction:myAction];

[character do:repeating];

character = [CCSprite spriteWithSpriteFrame:anim];
character.position = ccp(160, 240);
[self addChild:character];


提前致谢,
约翰

最佳答案

也许这只是一个剪切和粘贴错误,但是看起来您是在告诉精灵在创建它之前重复动画,因此要添加到节点的角色精灵永远不会发送CCAnimate操作。

关于iphone - Cocos2d中的动画。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2984499/

10-10 21:11