Draw() public method

Advances the time position and draws the current frame of the animation.
public Draw ( GameTime gameTime, BitmapBatch batch, Vector2 position, SpriteEffects spriteEffects ) : void
gameTime Microsoft.Xna.Framework.GameTime
batch BitmapBatch
position Vector2
spriteEffects SpriteEffects
return void
示例#1
0
        /// <summary>
        /// Draws the animated player.
        /// </summary>
        public void Draw(GameTime gameTime, BitmapBatch batch)
        {
            // Flip the sprite to face the way we are moving.
            if (Velocity.X > 0)
            {
                flip = SpriteEffects.FlipHorizontally;
            }
            else if (Velocity.X < 0)
            {
                flip = SpriteEffects.None;
            }

            // Draw that sprite.
            sprite.Draw(gameTime, batch, Position, flip);
        }
示例#2
0
        /// <summary>
        /// Draws the animated enemy.
        /// </summary>
        public void Draw(GameTime gameTime, BitmapBatch batch)
        {
            // Stop running when the game is paused or before turning around.
            if (!Level.Player.IsAlive ||
                Level.ReachedExit ||
                Level.TimeRemaining == TimeSpan.Zero ||
                waitTime > 0)
            {
                sprite.PlayAnimation(idleAnimation);
            }
            else
            {
                sprite.PlayAnimation(runAnimation);
            }


            // Draw facing the way the enemy is moving.
            SpriteEffects flip = direction > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            sprite.Draw(gameTime, batch, Position, flip);
        }