I am new in Cocos2d game developing. I have use more images for CCSprite animations. I am using that image like below code :
CCAnimation *animate=[CCAnimation animation];
[animate addFrameWithFilename:@"Criter1.png"];
[animate addFrameWithFilename:@"Criter2.png"];
[animate addFrameWithFilename:@"Criter3.png"];
[animate addFrameWithFilename:@"Criter4.png"];
CCAnimate *animation=[CCAnimate actionWithDuration:0.3f animation:animate restoreOriginalFrame:YES];
CCRepeatForever *repeat=[CCRepeatForever actionWithAction:animation];
[sprite runAction:repeat];
But i want to create a .plist
fie and use that in my code. So how can i make .plist
file and use it in my code ?
i want to create a .plist fie and use that in my code.
Ans : I am telling you line by line. please follow this and create .plist
file.
1- First open Zwoptex.
2- Click "Create a new document"
3- Click "Publish setting". (right side top corner)
4- Set your plist name & save target.
5- Click save.
6- Set your plist file width and height .(left side bar)
7- Drag and drop your all image.
8- Click "Layout" (Top left)
9- Then click "Publish" (top left)
10- Your .plist file is save in your target position.
how can i make .plist file and use it in my code ?
// First add that .plist file and .png in your project.
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sample.plist"];// retrive plist
NSMutableArray* CharAnim = [[NSMutableArray alloc] init];
for (int i = 0; i < 15; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"image%d.png",i]];
[CharAnim addObject:frame];
}
CCAnimation *animate=[CCAnimation animationWithSpriteFrames:CharAnim delay:0.045f];// Animation duration
CCAnimate *animation=[CCAnimate actionWithAnimation:animate];
CCRepeatForever *repeat=[CCRepeatForever actionWithAction:animation];// for repeat forever
[sprite runAction:repeat];// add on your sprite
I think this will help you. :)