动作-CCActionInterval之CCAnimation&CCAnimate

动画简单实例

v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}

Normal
0
false

10 pt
0
2

false
false
false

EN-US
ZH-CN
X-NONE

$([{£¥·‘“〈《「『【〔〖〝﹙﹛﹝$(.[{£¥
!%),.:;>?]}¢¨°·ˇˉ―‖’”…‰′″›℃∶、。〃〉》」』】〕〗〞︶︺︾﹀﹄﹚﹜﹞!"%'),.:;?]`|}~¢

/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:12.0pt;
font-family:Cambria;
mso-ascii-font-family:Cambria;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Cambria;
mso-hansi-theme-font:minor-latin;
mso-font-kerning:1.0pt;}

动作-CCActionInterval之CCAnimation&CCAnimate

pic2476.png

简单的动画代码:

CCSize winSize=CCDirector::sharedDirector()->getWinSize();         //#1:生成动画需要的数据类     CCTexture2D *texture=CCTextureCache::sharedTextureCache()->addImage(“pic2476.png”);    CCSpriteFrame *frame0=CCSpriteFrame::createWithTexture(texture,CCRectMake(32*0,48*0,32,48));    CCSpriteFrame *frame1=CCSpriteFrame::createWithTexture(texture,CCRectMake(32*1,48*0,32,48));    CCSpriteFrame *frame2=CCSpriteFrame::createWithTexture(texture,CCRectMake(32*2,48*0,32,48));    CCSpriteFrame *frame3=CCSpriteFrame::createWithTexture(texture,CCRectMake(32*3,48*0,32,48));     CCArray *arrayFrames=CCArray::create();    arrayFrames->addObject(frame0);    arrayFrames->addObject(frame1);    arrayFrames->addObject(frame2);    arrayFrames->addObject(frame3);     CCAnimation *animation=CCAnimation::createWithSpriteFrames(arrayFrames,0.2f);    //#2:初始化并设置Sprite    CCSprite *sprite=CCSprite::createWithSpriteFrame(frame0);    sprite->setPosition(ccp(winSize.width/2,winSize.height/2));    addChild(sprite);    //#3:使用animation生成一个动画动作animate     CCAnimate *animate=CCAnimate::create(animation);    sprite->runAction(CCRepeatForever::create(animate));

注意,cocos2dx不支持使用clip的动画,另外,clip动画的开发成本很高,在智能手机这种大内存的平台是否适用(牺牲内存换开发速度么?),值得商量。

#2 相关的类关系图

动作-CCActionInterval之CCAnimation&CCAnimate

简单过程是,使用CCTexture2D加载图片 ,用CCTexture2D生成对应的CCSpriteFrame(对应的就是帧),将CCSpriteFrame添加到CCAnimation生成动画数据,用CCAnimation生成CCAnimate(就是最终的动画动作),最后用CCSprite执行这个动作。

上一篇:HBase 使用场景和成功案例


下一篇:C语言 简单的栈