프레임 애니메이션
Animate를 사용하여 아주 쉽게 일정시간마다 이미지를 변경해주는 방식이다.아래의 예를 보자
C++
auto mySprite = Sprite::create("mysprite.png");
// now lets animate the sprite we moved
Vector<SpriteFrame*> animFrames;
animFrames.reserve(12);
animFrames.pushBack(SpriteFrame::create("Blue_Front1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Front2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Front3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Left3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Back3.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right1.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right2.png", Rect(0,0,65,81)));
animFrames.pushBack(SpriteFrame::create("Blue_Right3.png", Rect(0,0,65,81)));
// create the animation out of the frames
Animation* animation = Animation::createWithSpriteFrames(animFrames, 0.1f);
Animate* animate = Animate::create(animation);
// run it and repeat it forever
mySprite->runAction(RepeatForever::create(animate));
출처:http://cocos2d-x.org/docs/cocos2d-x/zh/actions/basic.html
'Cocos2d-x v3.17 > 기본기능' 카테고리의 다른 글
[Cocos2d-x 기본기능]Sequence,Spawn (0) | 2018.08.11 |
---|---|
[Cocos2d-x 기본기능]변속운동 (0) | 2018.08.11 |
[Cocos2d-x 기본기능]FadeIn,FadeOut,TintTo,TintBy (0) | 2018.08.11 |
[Cocos2d-x 기본기능] 이동,회전,스케일 (0) | 2018.08.11 |
[Cocos2d-x 기본기능]Action 소개 및 By 와 To 의 구별 (0) | 2018.08.11 |