2011年6月29日 星期三

cocos2d-使用plist處理動畫

之前看的知易教學所使用的CCSpriteSheet好像已經不能使用了 (我用1.0.0-rc),
在網路上有找到一篇教學寫得很詳細,


CCTexture2D *tex = [[CCTextureCache sharedTextureCache] addImage:@"Flowers.png"]; CCSpriteBatchNode *batch; batch = [FrameAnimHelper animWithTexture:tex                                numFrames:20   //plist裡面的frame數量                            plistFilename:@"Flowers.plist" //plist檔名                               spriteName:@"Flower"  //plist裡面的frame中的名字                                spriteTag:FLOWERS_SPRITE_TAG]; //tag名稱  [self addChild:batch];
做好.png跟.plist放到Resources裡面就可以直接撥動畫了,
要注意的是frame數量跟名字不要寫錯,
還有這篇的類別中的檔名格式是"%@-%04d.png",
若plist有自己統一命名規則的話可以直接去修改類別內容

沒有留言:

張貼留言