C# Class MonoGameFoundation.Sprite

A sprite to animate via a sprite sheet.
Inheritance: Microsoft.Xna.Framework.DrawableGameComponent
显示文件 Open project: half-ogre/MonoGameQuest

Public Methods

Method Description
Draw ( GameTime gameTime ) : void

Draws the sprite.

Initialize ( ) : void

Initializes the sprite.

This creates the SpriteBatch. If you override Initialize, be sure to call base.Initialize to create the SpriteBatch.

Sprite ( Microsoft.Xna.Framework.Game game, Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int pixelWidth, int pixelHeight, int pixelOffsetX, int pixelOffsetY ) : System

Creates a new Sprite instance.

Update ( GameTime gameTime ) : void

Updates the sprite's current animation.

Protected Methods

Method Description
BeginSpriteBatch ( ) : void

Calls SpriteBatch.Begin with default arguments. Override if you need to change the arguments to SpriteBatch.Begin.

Sprite ( Microsoft.Xna.Framework.Game game, Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int pixelWidth, int pixelHeight, int pixelOffsetX, int pixelOffsetY, Vector2 pixelPosition ) : System

Creates a new Sprite instance.

Method Details

BeginSpriteBatch() protected method

Calls SpriteBatch.Begin with default arguments. Override if you need to change the arguments to SpriteBatch.Begin.
protected BeginSpriteBatch ( ) : void
return void

Draw() public method

Draws the sprite.
public Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime The game's current time.
return void

Initialize() public method

Initializes the sprite.
This creates the SpriteBatch. If you override Initialize, be sure to call base.Initialize to create the SpriteBatch.
public Initialize ( ) : void
return void

Sprite() public method

Creates a new Sprite instance.
public Sprite ( Microsoft.Xna.Framework.Game game, Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int pixelWidth, int pixelHeight, int pixelOffsetX, int pixelOffsetY ) : System
game Microsoft.Xna.Framework.Game The global game instance.
spriteSheet Microsoft.Xna.Framework.Graphics.Texture2D The sprite sheet containing the sprite's animation frames.
pixelWidth int The width of the sprite in pixels.
pixelHeight int The height of the sprite in pixels.
pixelOffsetX int The sprite's X offset, used to to center the sprite on its location.
pixelOffsetY int The sprite's Y offset, used to to center the sprite on its location.
return System

Sprite() protected method

Creates a new Sprite instance.
protected Sprite ( Microsoft.Xna.Framework.Game game, Microsoft.Xna.Framework.Graphics.Texture2D spriteSheet, int pixelWidth, int pixelHeight, int pixelOffsetX, int pixelOffsetY, Vector2 pixelPosition ) : System
game Microsoft.Xna.Framework.Game The global game instance.
spriteSheet Microsoft.Xna.Framework.Graphics.Texture2D The sprite sheet containing the sprite's animation frames.
pixelWidth int The width of the sprite in pixels.
pixelHeight int The height of the sprite in pixels.
pixelOffsetX int The sprite's X offset, used to to center the sprite on its location.
pixelOffsetY int The sprite's Y offset, used to to center the sprite on its location.
pixelPosition Vector2 The sprite position in the display, in pixels.
return System

Update() public method

Updates the sprite's current animation.
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime The game's current time.
return void