1
我真的對cocos2d和o.c編程真的很陌生,我一直試圖弄清楚精靈動畫是如何工作的。 由於最新的更新,我得到了很多舊的代碼,不再工作。cocos2d動畫不斷崩潰
我有以下
(帶3個精靈,我想動畫spriteheet)不知何故,總是崩潰
這是我的init方法
[[CCSpriteFrameCache sharedSpriteFrameCache ] addSpriteFramesWithFile:@"eno_glasses.plist" ];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"eno_glasses.png"];
[self addChild:spriteSheet];
_body = [CCSprite spriteWithSpriteFrameName: [NSString stringWithFormat:@"eno_glasses02.png"]];
[spriteSheet addChild:_body];
_body.position = CGPointMake(screenSize.width/2, screenSize.height/2);
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 1; i < 3; i++) {
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"eno_glasses0%d.png",i]];
[animFrames addObject:frame];
}
CCAnimation *animation = [CCAnimation animationWithFrames:animFrames delay:0.03f];
CCAnimate* anime = [CCAnimate actionWithAnimation:animation];
[self runAction:anime];
我知道圖像可以被發現,因爲這個作品(我可以從plist得到圖像01,02,03)
我是否忘記了某個地方的零?
[[CCSpriteFrameCache sharedSpriteFrameCache ] addSpriteFramesWithFile:@"eno_glasses.plist" ];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"eno_glasses.png"];
[self addChild:spriteSheet];
_body = [CCSprite spriteWithSpriteFrameName: [NSString stringWithFormat:@"eno_glasses02.png"]];
[spriteSheet addChild:_body];
_body.position = CGPointMake(screenSize.width/2, screenSize.height/2);
另外我如何讓這個精靈動畫一次,然後等待幾秒鐘,再次動畫?使用刻度構造函數? – renevdkooi 2012-03-09 11:45:06