Esempio n. 1
0
            /// <summary>
            /// Draws the animation (located by <paramref name="position"/> parameter, rotated by <paramref name="rotation"/> parameter and scaled by <paramref name="scale"/> parameter) by <paramref name="sceneBatch"/> parameter on the scene.
            /// </summary>
            /// <param name="sceneBatch">The scene batch for drawing the animation.</param>
            /// <param name="position">The position of the animation.</param>
            /// <param name="rotation">The rotation of the animation.</param>
            /// <param name="scale">The scale of the animation.</param>
            /// <param name="effect">Effect to apply to the animation.</param>
            public void Draw(SceneBatch sceneBatch, Vector2 position, float rotation, Vector2 scale, SceneElementEffect effect)
            {
                if (sceneBatch.GameTime != null)
                {
                    elapsedTime += sceneBatch.GameTime.ElapsedGameTime.TotalMilliseconds;
                }

                if (elapsedTime >= Animation.Speed)
                {
                    ++actualFrame;
                    elapsedTime -= Animation.Speed;

                    if (actualFrame >= Animation.Frames.Count)
                    {
                        actualFrame = 0;
                    }
                }

                if (actualFrame < Animation.Frames.Count)
                {
                    sceneBatch.DrawTexture(Animation.Frames[actualFrame].TextureXna, ref position, rotation, ref scale, Animation.Frames[actualFrame].Origin, effect);
                }
            }
 /// <summary>
 /// Draws the texture (located by <paramref name="position"/> parameter, rotated by <paramref name="rotation"/> parameter and scaled by <paramref name="scale"/> parameter) by <paramref name="sceneBatch"/> parameter on the scene.
 /// </summary>
 /// <param name="sceneBatch">The scene batch for drawing the texture.</param>
 /// <param name="position">The position of the texture.</param>
 /// <param name="rotation">The rotation of the texture.</param>
 /// <param name="scale">The scale of the texture.</param>
 /// <param name="effect">Effect to apply to the texture.</param>
 public void Draw(SceneBatch sceneBatch, Vector2 position, float rotation, Vector2 scale, SceneElementEffect effect)
 {
     sceneBatch.DrawTexture(Texture.TextureXna, ref position, rotation, ref scale, Texture.Origin, effect);
 }