/// <summary> /// Starts playing an animation on this skeleton. /// </summary> /// <param name="name">Name of animation, as assigned in the Pose editor. Case sensitive.</param> /// <param name="startTimeSeconds">The starttime of the animation (first frame) in seconds. Often this will be the gametime of the current frame, but you can use this to offset the animation's time position.</param> public void StartAnimation(string name, float startTimeSeconds) { if (!_animations.TryGetValue(name, out var animation)) { throw new PoseAnimationNotFoundException($"Animation \"{name}\" not found."); } CurrentAnimation = animation; CurrentAnimation.Start(startTimeSeconds); }
public override void Draw(SpriteBatch spriteBatch) { //CurrentAnimationIndex = 0; if (!CurrentAnimation.IsStarted) { CurrentAnimation.Start(Repeat.Mode.Loop); } spriteBatch.Draw(CurrentAnimation, Position); if (Game1.DebugMode) { spriteBatch.DrawRectangle(CollisionBox, Color.Green); } }
private void timer1_Tick(object sender, EventArgs e) { if (CurrentAnimation == null) { CurrentAnimation = new Falling(this); } if (CurrentAnimation.Finished) { var animations = Assembly.GetExecutingAssembly().GetTypes().Where(t => string.Equals(t.Namespace, "scmpoo.animations.random")); var anim = animations.ElementAt(FormMain.RandomInst.Next(0, animations.Count())); CurrentAnimation = Activator.CreateInstance(anim, this) as Animation; } if (!CurrentAnimation.Started) { CurrentAnimation.Start(); CurrentAnimation.Started = true; } int interval = CurrentAnimation.Tick(); timer1.Interval = interval; }