コード例 #1
0
ファイル: ExampleGame.cs プロジェクト: warmuuh/SpriterDotNet
        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            float deltaTime = gameTime.ElapsedGameTime.Ticks / (float)TimeSpan.TicksPerMillisecond;

            stats.OnUpdate(deltaTime);
            Vector2 scale = animator.Scale;

            if (WasPressed(Keys.Enter))
            {
                SwitchEntity();
            }
            if (WasPressed(Keys.Space))
            {
                animator.Play(animator.GetNextAnimation());
            }
            if (WasPressed(Keys.O))
            {
                animator.ChangeAnimationSpeed(-0.2f, 5.0f);
            }
            if (WasPressed(Keys.P))
            {
                animator.ChangeAnimationSpeed(0.2f, 5.0f);
            }
            if (WasPressed(Keys.R))
            {
                animator.Speed = -animator.Speed;
            }
            if (WasPressed(Keys.X))
            {
                animator.Play(animator.Name);
            }
            if (WasPressed(Keys.T))
            {
                animator.Transition(animator.GetNextAnimation(), 1000.0f);
            }
            if (WasPressed(Keys.C))
            {
                animator.PushNextCharacterMap();
            }
            if (WasPressed(Keys.V))
            {
                animator.PopCharacterMap();
            }
            if (WasPressed(Keys.J))
            {
                animator.Color = animator.Color == Color.White ? Color.Red : Color.White;
            }

            if (WasPressed(Keys.W))
            {
                animator.Position += new Vector2(0, -10);
            }
            if (WasPressed(Keys.S))
            {
                animator.Position += new Vector2(0, 10);
            }
            if (WasPressed(Keys.A))
            {
                animator.Position += new Vector2(-10, 0);
            }
            if (WasPressed(Keys.D))
            {
                animator.Position += new Vector2(10, 0);
            }
            if (WasPressed(Keys.Q))
            {
                animator.Rotation -= 15 * (float)Math.PI / 180;
            }
            if (WasPressed(Keys.E))
            {
                animator.Rotation += 15 * (float)Math.PI / 180;
            }
            if (WasPressed(Keys.N))
            {
                animator.Scale -= new Vector2(Math.Sign(scale.X) * 0.2f, Math.Sign(scale.Y) * 0.2f);
            }
            if (WasPressed(Keys.M))
            {
                animator.Scale += new Vector2(Math.Sign(scale.X) * 0.2f, Math.Sign(scale.Y) * 0.2f);
            }
            if (WasPressed(Keys.F))
            {
                animator.Scale *= new Vector2(-1, 1);
            }
            if (WasPressed(Keys.G))
            {
                animator.Scale *= new Vector2(1, -1);
            }

            if (WasPressed(Keys.OemTilde))
            {
                (animator as MonoGameDebugAnimator).DrawSpriteOutlines = !(animator as MonoGameDebugAnimator).DrawSpriteOutlines;
            }
            if (WasPressed(Keys.OemMinus))
            {
                graphics.SynchronizeWithVerticalRetrace = !graphics.SynchronizeWithVerticalRetrace;
                graphics.ApplyChanges();
            }

            oldState = Keyboard.GetState();

            animator.Update(deltaTime);

            elapsedTime += deltaTime;
            if (elapsedTime >= 100)
            {
                elapsedTime -= 100;
                string entity = animator.Entity.Name;
                animatorInfo = string.Format("{0} : {1}", entity, animator.Name);
                metadata     = string.Format("Variables:\n{0}\nTags:\n", animator.GetVarValues(), animator.GetTagValues());
            }
        }