Cocos2D学习笔记之Animation初始化是本文要介绍的内容,主要来学习Animation,内容不多,汗很详细,我们来看详细内容,先来看Cocos2D中Animation的初始化的两种方式:
成都创新互联-专业网站定制、快速模板网站建设、高性价比湘阴网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式湘阴网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖湘阴地区。费用合理售后完善,十载实体公司更值得信赖。
(1).采用多张贴图
- Animation walkAnimation = [Animation animationWithName:@"walk" delay:0.1f];
- or(int i = 1; i < 5; i++)
- {
- [walkAnimation addFrameWithFilename:[NSString stringWithFormat:@"walk_%02d.png", i]];
- }
- id animate = [Animate actionWithAnimation:walkAnimation];
- RepeatForever *rep = [RepeatForever actionWithAction:animate];
- self runAction:rep];
(2).采用一张贴图(动作帧序列)
- CCSpriteSheet *mgr = [CCSpriteSheet spriteSheetWithFile:@"flight.png" capacity:5];
- CCSprite* flight = [CCSprite spriteWithTexture:mgr.texture rect:CGRectMake(0,0,31,30)];
- flight.position = ccp(300, 0);
- flight.scale = 1.1;
- flight.anchorPoint = ccp(0.0f, 0.0f);
- [mgr addChild:flight z:1 tag:99];
- CCAnimation *animation = [CCAnimation animationWithName:@"flight" delay:0.2f];
- for(int i = 0; i < 3; i++)
- {
- int x= i % 3;
- [animation addFrameWithTexture:mgr.texture rect:CGRectMake(x*32, 0, 31, 30) ];
- }
- id action = [CCAnimate actionWithAnimation: animation];
- [flight runAction:[CCRepeatForever actionWithAction:action]];
小结:Cocos2D学习笔记之Animation初始化的内容介绍完了,希望本文对你有所帮助!
分享名称:Cocos2D学习笔记之Animation初始化
链接URL:http://www.gawzjz.com/qtweb2/news25/20375.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联