新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
Cocos2D學(xué)習(xí)筆記之Animation初始化
Cocos2D學(xué)習(xí)筆記之Animation初始化是本文要介紹的內(nèi)容,主要來(lái)學(xué)習(xí)Animation,內(nèi)容不多,汗很詳細(xì),我們來(lái)看詳細(xì)內(nèi)容,先來(lái)看Cocos2D中Animation的初始化的兩種方式:

成都創(chuàng)新互聯(lián)-專(zhuān)業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性?xún)r(jià)比湘陰網(wǎng)站開(kāi)發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫(kù),直接使用。一站式湘陰網(wǎng)站制作公司更省心,省錢(qián),快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋湘陰地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴(lài)。
(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).采用一張貼圖(動(dòng)作幀序列)
- 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]];
小結(jié):Cocos2D學(xué)習(xí)筆記之Animation初始化的內(nèi)容介紹完了,希望本文對(duì)你有所幫助!
文章標(biāo)題:Cocos2D學(xué)習(xí)筆記之Animation初始化
文章網(wǎng)址:http://fisionsoft.com.cn/article/djohdod.html


咨詢(xún)
建站咨詢(xún)
