public void PlayAnimation(Animation animation) { // If this animation is already running, do not restart it. if (Animation == animation) return; // Start the new animation. Animation = animation; FrameIndex = 0; }
public AddAnimationScreen(ScreenManager manager, Resources resources) : base(manager) { OpeningTransition = new NoneTransition(Transition.Types.Opening); ClosingTransition = new NoneTransition(Transition.Types.Closing); IsSubmitted = false; Resources = resources; animCurrentlyBuilding = new Animation(Resources, new string[] { }, 1, true); animPlayer = new AnimationPlayer(); }
public void Add(string name, Animation animation) { if (!Animations.ContainsKey(name)) Animations.Add(name, animation); }
public string GetName(Animation anim) { if (Animations.ContainsValue(anim)) return Animations.Where(pair => pair.Value == anim).First().Key; return ""; }
public override void Update(GameTime gameTime, bool isInForeground) { base.Update(gameTime, isInForeground); if (!isInForeground) return; panel.Update(gameTime); if (toRightButton.IsPressed() && spriteLib.SelectedItem != null) { spriteSelected.AddToList(spriteLib.SelectedItem); UpdateAnimation(); } if (toLeftButton.IsPressed() && spriteSelected.SelectedItem != null) { spriteSelected.RemoveFromList(spriteSelected.SelectedIndex); UpdateAnimation(); } if (toUpButton.IsPressed() && spriteSelected.SelectedItem != null && spriteSelected.SelectedIndex > 0) { List<string> items = spriteSelected.Items; int index = spriteSelected.SelectedIndex; items.RemoveAt(index); items.Insert(index - 1, spriteSelected.SelectedItem); spriteSelected.RemoveAllFromList(); foreach (string s in items) spriteSelected.AddToList(s); } if (toDownButton.IsPressed() && spriteSelected.SelectedItem != null && spriteSelected.SelectedIndex < spriteSelected.Items.Count - 1) { List<string> items = spriteSelected.Items; int index = spriteSelected.SelectedIndex; items.RemoveAt(index); items.Insert(index + 1, spriteSelected.SelectedItem); spriteSelected.RemoveAllFromList(); foreach (string s in items) spriteSelected.AddToList(s); } float frameTime = animCurrentlyBuilding.FrameTime; float.TryParse(frameTimeTextBox.Text, out frameTime); animCurrentlyBuilding.FrameTime = frameTime; animCurrentlyBuilding.SpriteEffect = (SpriteEffects)Enum.Parse(typeof(SpriteEffects), effectButton.List[effectButton.CurrentIndex]); if (addAnimationButton.IsPressed() && animCurrentlyBuilding.FrameCount > 0 && !String.IsNullOrWhiteSpace(addSpriteText.Text)) { Resources.Add(addSpriteText.Text, animCurrentlyBuilding); animCurrentlyBuilding = new Animation(Resources, new string[] { }, 1, true); UpdateAnimation(); } if (submitButton.IsPressed()) { IsSubmitted = true; Manager.CloseScreen(); return; } }