DragonBones / DragonBonesAS

DragonBones ActionScript Runtime
MIT License
250 stars 117 forks source link

Animation control (reset, loop) #48

Closed SudoPlz closed 8 years ago

SudoPlz commented 10 years ago

Hey guys,

1) first of all I would like to know how I can reset the animation back to frame 0 after it has successfuly completed?

2) is there a loop property (it would be great if there was an animation.loop property) so that you can set if you want the animation to loop or not on the fly?

Thanks

SudoPlz commented 10 years ago

Right now I use this code to reset the animation back to frame 0.. Is it correct?

private function resetArmature(arm:Armature):void {
    arm.animation.stop();
    if(arm.animation.lastAnimationState)
    {
        arm.animation.gotoAndPlay(arm.animation.lastAnimationState.name,0);
    }else{
        arm.animation.play();
    }
    arm.animation.lastAnimationState.currentTime = 0;
    arm.advanceTime(0);
    arm.animation.stop();
}
bobrokrol commented 8 years ago

I had same issue year ago and have it right now. Is it possible to reset animation to first frame and stop?

akdcl commented 8 years ago

Now, you can use armature.animation.gotoAndStopByTime()