许多类都被改变了,旧的方法似乎不起作用.
NSMutableArray *animFrames = [NSMutableArray array]; for(int i = 1; i <= 3; i++) { CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByname:[Nsstring stringWithFormat:@"Sprite-%d.png",i]]; [animFrames addobject:frame]; } CCAnimation *animation = [CCAnimation animationWithname:@"run" delay:0.1f frames:animFrames]; [mySprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO]]];
任何的想法?
谢谢.
额外信息
解决方法 这是它的工作原理:NSMutableArray *animationFrames = [NSMutableArray array]; for(int i = 1; i <= FRAMES; ++i) { CCSpriteFrame *spriteFrame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByname: [Nsstring stringWithFormat:@"animationFrame%d.png",i]]; // } //Create an animation from the set of frames you created earlIEr CCAnimation *animation = [CCAnimation animationWithSpriteFrames: animationFrames delay:delay]; //Create an action with the animation that can then be assigned to a sprite CCActionAnimate *animationAction = [CCActionAnimate actionWithAnimation:animation]; CCActionRepeatForever *repeatingAnimation = [CCActionRepeatForever actionWithAction:animationAction]; [self runAction:repeatingAnimation];总结
以上是内存溢出为你收集整理的ios – 如何在Cocos2D 3.x中为CCSprite制作动画?全部内容,希望文章能够帮你解决ios – 如何在Cocos2D 3.x中为CCSprite制作动画?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)