如何使用Zwoptex创建plist?

时间:2014-05-05 05:28:50

标签: ios cocos2d-iphone plist zwoptex

我是Cocos2d游戏开发的新手。我为CCSprite动画使用了更多图像。我使用的图像如下代码:

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];

但我想创建一个.plist fie并在我的代码中使用它。那么如何制作.plist文件并在我的代码中使用它呢?

1 个答案:

答案 0 :(得分:2)

  

我想创建一个.plist fie并在我的代码中使用它。

答:我正在逐行告诉你。请按照此操作创建.plist文件。

1-首先打开Zwoptex。

enter image description here

2-单击"创建新文档"

3-单击"发布设置"。 (右上角)

4-设置你的plist名称&保存目标。

5-点击保存。

enter image description here

6-设置plist文件的宽度和高度。(左侧栏)

7-拖放所有图像。

enter image description here

8-点击"布局" (左上)

enter image description here

9-然后点击"发布" (左上)

enter image description here

10-您的.plist文件将保存在目标位置。

  

如何制作.plist文件并在我的代码中使用它?

// 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

我认为这会对你有所帮助。 :)