美图齐众专注资阳网站设计 资阳网站制作 资阳网站建设
资阳网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

Cocos2D学习笔记之Animation初始化

Cocos2D学习笔记之Animation初始化是本文要介绍的内容,主要来学习Animation,内容不多,汗很详细,我们来看详细内容,先来看Cocos2DAnimation的初始化的两种方式:

成都创新互联-专业网站定制、快速模板网站建设、高性价比湘阴网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式湘阴网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖湘阴地区。费用合理售后完善,十载实体公司更值得信赖。

(1).采用多张贴图

 
 
  1. Animation walkAnimation = [Animation animationWithName:@"walk" delay:0.1f];    
  2. or(int i = 1; i < 5; i++)    
  3. {    
  4.  [walkAnimation addFrameWithFilename:[NSString stringWithFormat:@"walk_%02d.png", i]];    
  5. }    
  6. id animate = [Animate actionWithAnimation:walkAnimation];    
  7. RepeatForever *rep = [RepeatForever actionWithAction:animate];    
  8.      
  9. self runAction:rep];  

(2).采用一张贴图(动作帧序列)

 
 
  1. CCSpriteSheet *mgr = [CCSpriteSheet spriteSheetWithFile:@"flight.png" capacity:5];    
  2.  CCSprite* flight = [CCSprite spriteWithTexture:mgr.texture rect:CGRectMake(0,0,31,30)];    
  3.  flight.position = ccp(300, 0);    
  4.  flight.scale = 1.1;    
  5.  flight.anchorPoint = ccp(0.0f, 0.0f);    
  6.  [mgr addChild:flight z:1 tag:99];    
  7.             
  8.  CCAnimation *animation = [CCAnimation animationWithName:@"flight" delay:0.2f];    
  9.  for(int i = 0; i < 3; i++)     
  10.  {    
  11.     int x= i % 3;    
  12.     [animation addFrameWithTexture:mgr.texture rect:CGRectMake(x*32, 0, 31, 30) ];    
  13.  }    
  14.  id action = [CCAnimate actionWithAnimation: animation];    
  15. [flight runAction:[CCRepeatForever actionWithAction:action]];  

小结:Cocos2D学习笔记之Animation初始化的内容介绍完了,希望本文对你有所帮助!


文章题目:Cocos2D学习笔记之Animation初始化
网页地址:http://zsjierui.cn/article/djohdod.html

其他资讯