1.首先将需要渲染的精灵图片用zwoptex软件生成一个.plist和.png文件。
2.建一个精灵帧缓存,以便将上文中建立的.plist文件中的精灵帧存入进去。
CCSpriteFrameCache* spriteFrameCache = [CCSpriteFrameCache sharedSpriteFrameCache];
3.通过addSrpiteFrameWithFile方法从plist文件中添加精灵帧。与此同时,纹理也将会通过1中建立的png文件自动载入。
[spriteFrameCache addSpriteFrameWithFile:@"SpriteSheet.plist"]; // SpriteSheet.plist 为上文建立的plist文件的名字。
4.通过1中建立的png图片,建立一个精灵表单。
CCSptireBatchNode *batchNode = [CCSpriteBatchNode batchNodeWithFile:@"SpriteSheet.png"];
batchNode.position = CGPointZero;
[self addChild:batchNode];
现在已经有了精灵帧了,也把这些精灵帧都加到了精灵表单了,下面就可以通过这些精灵帧创建精灵了。
5.首先要从精灵帧缓存中取出相应的精灵帧。
CCSptireFrame *bgSpriteFrame = [spriteFrameCache spriteFrameByName:@"gamebg