忍者ブログ
  • 2024.08
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 2024.10
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【2024/09/18 01:12 】 |
cocos2d-xのアニメーション
cocosでアニメーション作成する

以下は、立っている絵から歩きアニメーションを再生するところ。

standSprite = Sprite::create("stand.png");

Animation* walkAnimation;
walkAnimation = Animation::create();
walkAnimation->addSpriteFrame(cache->getSpriteFrameByName("walk_1.png"));
walkAnimation->addSpriteFrame(cache->getSpriteFrameByName("walk_2.png"));
walkAnimation->setDelayPerUnit(0.5f);
walkAnimation->setRestoreOriginalFrame(true); //(A)

Animate* animate = Animate::create(walkAnimation);
standSprite->runAction(RepeatForever::create(animate));



standSpriteは、アニメーションを再生しなければ単なるスプライト。
アニメーション(この場合スプライトアニメーション)を再生することで、立ち絵のスプライトが歩きスプライトのアニメーションに変わる。
setRestoreOriginalFrame(true)
を指定していると、アニメーションが終了したときに元のスプライト(立ち絵の表示)に戻る。ただしここではRepeatForeverアニメーションなので、終了することがないので設定が無意味だが。






PR
【2014/12/09 12:33 】 | cocos2d-x | 有り難いご意見(0)
<<cocos2d-xの参照カウンタについて | ホーム | Xcodeでメモリ周りのデバッグ>>
有り難いご意見
貴重なご意見の投稿














<<前ページ | ホーム | 次ページ>>