自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Cocos2D學(xué)習(xí)筆記之Animation初始化

移動(dòng)開發(fā) iOS 游戲開發(fā)
本文介紹的是Cocos2D學(xué)習(xí)筆記之Animation初始化,主要通過(guò)兩個(gè)小實(shí)例來(lái)認(rèn)識(shí)和學(xué)習(xí)Animation,來(lái)看內(nèi)容。

Cocos2D學(xué)習(xí)筆記之Animation初始化是本文要介紹的內(nèi)容,主要來(lái)學(xué)習(xí)Animation,內(nèi)容不多,汗很詳細(xì),我們來(lái)看詳細(xì)內(nèi)容,先來(lái)看Cocos2DAnimation的初始化的兩種方式:

(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).采用一張貼圖(動(dòng)作幀序列)

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

小結(jié):Cocos2D學(xué)習(xí)筆記之Animation初始化的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!

責(zé)任編輯:zhaolei 來(lái)源: 博客園
相關(guān)推薦

2011-08-11 18:00:18

Cocos2d動(dòng)作Action

2011-08-02 15:37:48

Cocos2D UIAccelero

2011-08-11 17:52:01

Cocos2d游戲對(duì)象

2011-07-08 16:09:54

Cocoa Cocos2d 動(dòng)作

2011-08-09 16:08:58

IOS游戲Cocos2d

2011-07-08 16:27:52

Cocoa Cocos2d 動(dòng)作

2011-08-17 15:04:48

Cocos2DUIAccelerom加速計(jì)

2011-07-27 10:13:23

Cocos2D iPhone

2011-07-29 18:02:06

2012-06-01 10:27:44

Cocos2d觸摸分發(fā)原理

2011-08-15 17:52:21

iPhone應(yīng)用對(duì)象NSString

2011-08-04 17:01:16

iPhone游戲開發(fā) Cocos2d

2011-08-11 14:22:47

iPhone游戲Cocos2D

2011-08-11 14:32:04

iPhone游戲Cocos2dActions

2012-02-19 20:10:23

Cocos2d-x fCocos2dWindows Pho

2011-07-27 13:44:08

2011-07-20 14:04:46

Cocos2d iPhone 游戲

2011-08-09 16:25:16

Cocos2d視圖坐標(biāo)

2011-07-27 14:48:21

iPhone Cocos2D 坐標(biāo)

2011-08-08 11:26:39

Cocos2d 游戲 Class類
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)