Manipulating animationStart
and animationEnd
mid-playback is interesting, though I've not tried it and I'm not sure what else it may affect. You don't generally want to set private fields (starting with _
).
It's likely easiest to use 3 track entries instead of manipulating a single entry. Eg:
intro = state.setAnimation(0, "animation", false);
intro.animationEnd = 0.25; // intro end time
loop = state.addAnimation(0, "animation", true, 0);
loop.animationStart = 0.25; // intro end time
loop.animationEnd = 0.75; // loop end time
outro = state.addAnimation(0, "animation", false, 6); // 6 is duration to play loop
outro.animationStart = 0.75; // loop end time
You could postpone adding the outro if you want to play the looping part for an indefinite amount of time. In that case you'd probably set the addAnimation
delay to 0, so the outro starts at the end of the next loop.