• Runtimes
  • Starling Help? How to stop at frame/seconds in animation

Hi, I have an animation that loads up and I can click the asset to have it play the animation. Thats great.

The issue I have is, when the asset first loads up it appears to be resting on the very last frame of the Spine animation and not the first frame.
How can I get the animation asset to be forced to the first frame of the animation?
I was looking for something like skeleton.state.setAnimationFrame(0);
similar to gotoAndStop(1) in AS3

Thanks

  • Patrick
addEventListener( TouchEvent.TOUCH, onClick );
var json : SkeletonJson = new SkeletonJson( new StarlingAtlasAttachmentLoader( sAssets.getTextureAtlas( "spine-texture" ) ) );
var skeletonData : SkeletonData = json.readSkeletonData( sAssets.getObject( "spine-json" ) );

skeleton = new SkeletonAnimation( skeletonData, true );
         
addChild( skeleton ); private function onClick(event : TouchEvent) : void { Starling.juggler.add( skeleton ); var touch : Touch = event.getTouch( this ); if (touch && touch.phase == TouchPhase.BEGAN) { skeleton.state.setAnimationByName( 0, "intro", false ); } }
Related Discussions
...
  • Змінено

The skeleton should be in the setup pose until you pose it otherwise. You can call Animation#apply to pose the skeleton, or something like:

AnimationState state = ...
state.setAnimationByName(0, "intro", false);
state.apply(skeleton.skeleton);
state.clearTrack(0);

that works. It seems to reset the animation to the first frame.
Thanks