cocos2d-x で実行中のアニメーション/アクションから現在のフレームを取得することは可能ですか? iSDone という関数がありますが、スプライトのブール値を 1 回実行するアクションが提供され、スプライト データも提供されません。
アクションの実行中に現在のフレームの高さ、幅、x、および y が必要です。
方法はありますか?
cocos2d-x で実行中のアニメーション/アクションから現在のフレームを取得することは可能ですか? iSDone という関数がありますが、スプライトのブール値を 1 回実行するアクションが提供され、スプライト データも提供されません。
アクションの実行中に現在のフレームの高さ、幅、x、および y が必要です。
方法はありますか?
int CCAnimationHelper::frameOfAnimation(cocos2d::CCAnimation *animation, cocos2d::CCSprite *sprite){
CCTexture2D* tex = sprite->getTexture();
int imageIndex = 0;
for (int i=0; i<animation->getFrames()->count(); i++) {
CCAnimationFrame *frame = (CCAnimationFrame*)animation->getFrames()->objectAtIndex(i);
CCTexture2D *tex2 = frame->getSpriteFrame()->getTexture();
if (tex->isEqual(tex2)) {
imageIndex = i;
break;
}
}
return imageIndex;
}