iphone - 播放 png 序列

标签 iphone ios cocos2d-iphone

我正在尝试使用以下代码在我的应用程序中播放一系列 PNG:

animatedSprite = [CCSprite spriteWithFile:@"Anim_1.png"];
animatedSprite.position = ccp( 512, 435 );
[self animatedSprite z:5];

NSArray *animFrames = [[NSArray alloc] initWithObjects:
                       [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"Anim_1.png"],
                       [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"Anim_2.png"], nil];

spriteAnim = [CCAnimation animationWithSpriteFrames:animFrames delay:1.0f/24.0f];

id animAction = [CCAnimate actionWithAnimation:spriteAnim];
[spriteAnim runAction:animAction];

“animatedSprite”已正确添加,但动画无法播放。我在这里缺少什么?

我使用的是Cocos2d 2.0,xcode 4.5

最佳答案

您应该在 Sprite 上运行操作,而不是动画。

[animatedSprite runAction:animAction];

关于iphone - 播放 png 序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13218152/

相关文章:

iphone - 在未从操作调用时使用 IBAction 方法?

ios - 如何检查 iOS 是否有可用的更新?

iphone - 声纳效应的方向?

iphone - iOS:如何确定 CPU 类型,例如A4还是A5,或者指令集架构arm6还是arm7?

iPhone SDK : How to add an outline to UILabel's text

iphone - 移动 safari 忽略 navigator.geolocation?

ios - getdatainbackgroundwithblock 返回 nil

ios - Swift 中的 TextView 屏幕截图?

iphone - dyld : Library not loaded:/usr/lib/libc++abi. dylib

ios - 在box2d中制动对象中的所有关节