public void SetCurrentAnimation(string name) { if (!_animations.ContainsKey(name)) { throw new ArgumentException("cannot find the animation: " + name); } if (name != _currentAnimation) { if (!CurrentAnimation.FinishBeforeTransition) { // Switch immediately to the new animation _currentAnimation = name; CurrentAnimation.Reset(); } else { // Set the current animation to wait for the end, upon finishing, switch animations CurrentAnimation.WaitForEnd(); EventHandler <AnimationEventArgs> animSwitch = (sender, args) => { _currentAnimation = name; CurrentAnimation.Reset(); }; CurrentAnimation.AnimationFinished += animSwitch; } } }
public override void Reset() { if (!IsGhost) { CurrentAnimation = ConstructionAnimation; CurrentAnimation.Reset(); } }
internal void SetAnimation(SPRITE_ANIMATION newAnimationState) { if (newAnimationState != CurrentAnimationState) { CurrentAnimationState = newAnimationState; CurrentAnimation.Reset(); } }
public void ResetAnimation() { if (CurrentAnimation == null) { return; } CurrentAnimation.Reset(); }
/// <summary> /// Set the current animation to a specific frame. /// </summary> /// <param name="frame">The frame in terms of the animation.</param> public void SetFrame(int frame) { if (!Active) { return; } CurrentAnimation.CurrentFrameIndex = frame; CurrentAnimation.Reset(); }
/// <summary> /// Plays an animation. If no animation is specified, play the buffered animation. /// </summary> public void Play() { Active = true; if (BufferedAnimation != null) { Play(BufferedAnimation.Name); } else { CurrentAnimation.Reset(); } }
public Animation Play(string key) { Animation anim; if (Animations.TryGetValue(key, out anim)) { //Console.WriteLine("playing anim " + key); CurrentAnimation = anim; CurrentAnimation.Reset(); return(anim); } return(null); }
public void Play(string a) { if (!Animations.ContainsKey(a)) { Debugger.Instance.Log("Cannot play animation " + a + " on " + Name); return; } Active = true; var pastAnim = CurrentAnimation.Name; CurrentAnimationName = a; if (CurrentAnimation != Animations[pastAnim]) { CurrentAnimation.Reset(); } }
internal virtual void SetCurrentAnimationByName(string name, double?overrideDelay = null) { if (CurrentAnimation != null) { //CurrentAnimation.OnAnimationDidStart = null; //CurrentAnimation.OnAnimationDidFinish = null; } SpriteAnimation animation = (from anim in allAnimations where anim.Name.ToLowerInvariant() == name.ToLowerInvariant() select anim).FirstOrDefault(); if (animation != null) { CurrentAnimation = animation; if (overrideDelay != null) { CurrentAnimation.FrameDelay = overrideDelay.Value; } CurrentAnimation.Reset(); } }
public Animation Play(string key) { Animation anim; if (Animations.TryGetValue(key, out anim)) { // check if the current animation that is playing // is not already the one we want to play if (CurrentAnimation?.Name == key && CurrentAnimation.IsPlaying) { return(CurrentAnimation); } CurrentAnimation = anim; CurrentAnimation.Reset(); return(anim); } return(null); }
public void SetAnimationFrameRate(float frameRate, bool allFrames) { if (CurrentAnimation == null) { return; } if (allFrames) { CurrentAnimation.FrameRate = frameRate; } else { foreach (var frame in SelectedFrames) { CurrentAnimation.SetFrameDuration(frame.Num, 1f / frameRate); } } CurrentAnimation.Reset(); }
/// <summary> /// Resets the current animation back to the first frame. /// </summary> public void Reset() { CurrentAnimation.Reset(); }