void SpineTestLayer::update (float deltaTime) {
if (skeletonNode->states[0]->loop) {
if (skeletonNode->states[0]->time > 2)
skeletonNode->setAnimation("jump", false);
} else {
if (skeletonNode->states[0]->time > 1)
skeletonNode->setAnimation("walk", true);
}
}
this is use the time to determine something,But It is not precise,For example:
if (skeletonNode->states[0]->time == 0.318){
attackCheck();
} else if(skeletonNode->states[0]->time == 0.618){
attackCheck();
}
I just want make the "attackCheck" once at the '0.318' and '0.618',So I use "==",But actually,the time can't catch the point "0.138" precise.
So I want know Is there one way to get the current frame index at the method "update".I can do like this:
if (skeletonNode->states[0]->frameIndex == 12){
attackCheck();
} else if(skeletonNode->states[0]->frameIndex == 18){
attackCheck();
}