您的位置:首页 > 职场人生

职业人生:网友10年跳槽经验总结

2011-10-25 01:33 477 查看
今晚查了下资料,发现有很多版本,但都大同小异,自己参照代码做了一个例子

准备工作:

1、用Flash制作好每帧的png图片;

2、用Zwoptex或texturepacker生成 .png 和 .plist 文件;

把 .png 和 .plist 文件导入到工程中,剩下的就只剩编码了:

//在 .h 中:
NSMutableArray *arr;
CCSprite *anim;
CCSpriteBatchNode * _batchNode;
//在.m 中:
CGSize size = [[CCDirector sharedDirector] winSize];
_batchNode = [CCSpriteBatchNode batchNodeWithFile:@"game.png"];
[self addChild:_batchNode];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"game.plist"];

arr = [NSMutableArray array];

for (int i = 235; i <= 353; i++) {
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString               stringWithFormat:@"game-%d.png",i]];
[arr addObject: frame];
}

anim = [CCSprite spriteWithSpriteFrameName:@"game-235.png"];
anim.position = ccp(size.width/2, size.height/2);
[self addChild:anim];

CCAnimation *animation = [CCAnimation animationWithFrames:arr delay:0.3f];
CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
[anim runAction:animate];


本文出自 “youthpasses” 博客,请务必保留此出处http://youthpasses.blog.51cto.com/2909834/780135
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: