Search code examples
ioscocos2d-iphoneplistzwoptex

How to create plist using Zwoptex?


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 ?


Solution

  • 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.

    enter image description here

    2- Click "Create a new document"

    3- Click "Publish setting". (right side top corner)

    4- Set your plist name & save target.

    5- Click save.

    enter image description here

    6- Set your plist file width and height .(left side bar)

    7- Drag and drop your all image.

    enter image description here

    8- Click "Layout" (Top left)

    enter image description here

    9- Then click "Publish" (top left)

    enter image description here

    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. :)