Platformer.Player.Draw C# (CSharp) Method

Draw() public method

Draws the animated player.
public Draw ( GameTime gameTime, SpriteBatch spriteBatch ) : void
gameTime Microsoft.Xna.Framework.GameTime
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
return void
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Draw that sprite.
            sprite.Draw(gameTime, spriteBatch, Position, SpriteEffects.None);
        }

Usage Example

Example #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue); // Draw background

            spriteBatch.Begin();

            for (int i = 0; i < bullets.Count; i++) // Draw bullets
            {
                bullets[i].Draw(spriteBatch);
            }

            for (int i = 0; i < platforms.Count; i++) // Draw platforms
            {
                platforms[i].Draw(spriteBatch);
            }

            for (int i = 0; i < enemies.Count; i++) // Draw enemies and their health bars
            {
                enemies[i].Draw(spriteBatch);
                healthBars[i].Draw(spriteBatch, gun.Damage);
            }

            player.Draw(spriteBatch);  // Draw player

            glasses.Draw(spriteBatch); // Draw glasses

            if (isTurnedLeft == true)
            {
                gun.DrawLeft(spriteBatch); // Draw left gun
            }
            else
            {
                gun.DrawRight(spriteBatch);                                                                 // Draw right gun
            }
            spriteBatch.Draw(crosshairTex, new Vector2(mouseState.X - 10, mouseState.Y - 10), Color.White); // Draw crosshair

            spriteBatch.End();

            base.Draw(gameTime);
        }
All Usage Examples Of Platformer.Player::Draw