LoginSignup
1
1

More than 5 years have passed since last update.

cocos2d-xでSpriteがアニメーション中かどうかを判別する

Posted at

これも備忘録代わりに。
(※cocos2d-x v2.x系で記述してます)

numberOfRunningActions()

sample
   CCSprite *sprite = CCSprite::create("hoge.png");
   int animCount = sprite->numberOfRunningActions();

   CCLOG("runnning animation count >> %d", animCount);
   // runnning animation count >> 0

アニメーション中(runAction中)であれば、動かしてる分の数値が返ってきます。
何もアニメーションをしていない時は0が返ってくるようになってます。

※サンプルはCCSpriteですが、numberOfRunningActions()自体はCCNodeクラスにいるので、CCNodeを継承しているクラスであれば使用可能です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1