Method | Description | |
---|---|---|
Sprite ( ) : System |
Initializes a Sprite at the origin which will match the dimensions of its texture when the texture is loaded
|
|
Sprite ( int x, int y ) : System |
Initializes a Sprite at the given position. It will match the dimensions of its texture when the texture is loaded.
|
|
Sprite ( int x, int y, int width, int height ) : System |
Initializes a Sprite at the given position with the given dimensions
|
|
draw ( |
Draws this sprite. Call this method on every Sprite in the Game's draw cycle. Override this method in child classes as necessary (i.e. if drawing additional components)
|
|
getAnimationTime ( ) : float | ||
getBoundingRect ( ) : Rectangle | ||
getColor ( ) : Color | ||
getCommonImage ( string imageFileName ) : Texture2D |
Retrieves a pre-loaded 2D texture to associate with an instantiated Sprite object. Good for multiple objects using the same texture
|
|
getHeight ( ) : int | ||
getImage ( ) : Texture2D | ||
getImageColumns ( ) : int | ||
getImageRows ( ) : int | ||
getWidth ( ) : int | ||
getX ( ) : int | ||
getXCenter ( ) : int | ||
getY ( ) : int | ||
getYCenter ( ) : int | ||
isVisible ( ) : bool | ||
loadCommonImage ( ContentManager content, string imageFileName ) : void |
Loads a 2D texture in the "Content" directory for use by multiple Sprite objects. Call this method in the loading content cycle, and when instantiating new objects in-game, call getCommonImage()
|
|
loadContent ( ContentManager content ) : void |
Loads all content necessary for this Sprite. Call this method on every Sprite in the Game's load cycle. Override this method when writing the classes that must load specific sprites and sound effects.
|
|
loadImage ( ContentManager content, string fileName ) : void |
Loads a static 2D texture with the given filename in the "Content" directory
|
|
loadImage ( ContentManager content, string fileName, int numRows, int numCols, float anTime ) : void |
Loads a 2D spritesheet with the given filename in the "Content" directory
|
|
onCollide ( IInteractable other ) : void | ||
onInteract ( ) : void | ||
reset ( ) : void | ||
setCenter ( int x, int y ) : void |
Sets the position of this Sprite with given center coordinates
|
|
setColor ( Color color ) : void | ||
setDimensions ( int width, int height ) : void |
Sets the dimensions of this Sprite
|
|
setHeight ( int height ) : void | ||
setImage ( Texture2D image ) : void |
Sets a static 2D texture that has already been loaded to be used to draw this Sprite
|
|
setImage ( Texture2D image, int numRows, int numCols, float anTime ) : void |
Sets an animating 2D texture that has already been loaded to be used to draw this Sprite
|
|
setPosition ( int x, int y ) : void |
Sets the position of this Sprite given the coordinates of its top-left corner
|
|
setSourceRect ( int x, int y, int width, int height ) : void |
Sets the source rectangle of a loaded texture for this Sprite (if the particular texture is a collection of different sprites).
|
|
setVisible ( bool visible ) : void | ||
setWidth ( int width ) : void | ||
setX ( int x ) : void | ||
setXCenter ( int x ) : void | ||
setY ( int y ) : void | ||
setYCenter ( int y ) : void | ||
unloadCommonImages ( ) : void |
Clears memory of all loaded textures. Be sure to call unload on the ContentManager as well.
|
|
update ( float elapsed ) : void |
Updates this sprite based on time. If the sprite can animate, then it will do so here. Call this method on every Sprite in the Game's update cycle. Override this method in child classes as necessary.
|
Method | Description | |
---|---|---|
matchToTextureDimensions ( ) : void | ||
resetAnimation ( ) : void | ||
setAnimationTime ( float time ) : void | ||
setFrameColumn ( int col ) : void | ||
setFrameRow ( int row ) : void | ||
setImageColumns ( int cols ) : void | ||
setImageRows ( int rows ) : void |
Method | Description | |
---|---|---|
nullCheck ( ) : void | ||
searchDirectories ( ContentManager content, string fileName ) : Texture2D |
public Sprite ( int x, int y ) : System | ||
x | int | X coordinate of top-left corner |
y | int | Y coordinate of top-left corner |
return | System |
public Sprite ( int x, int y, int width, int height ) : System | ||
x | int | X coordinate of top-left corner |
y | int | Y coordinate of top-left corner |
width | int | Width in pixels; specify 0 to use texture dimensions |
height | int | Height in pixels; specify 0 to use texture dimensions |
return | System |
public draw ( |
||
sb | SpriteBatch passed in through Game | |
return | void |
public static getCommonImage ( string imageFileName ) : Texture2D | ||
imageFileName | string | The file name of the image that was previously loaded |
return | Texture2D |
public static loadCommonImage ( ContentManager content, string imageFileName ) : void | ||
content | ContentManager | The content manager |
imageFileName | string | The file name of the image, without the extension |
return | void |
public loadContent ( ContentManager content ) : void | ||
content | ContentManager | ContentManager passed in through Game |
return | void |
public loadImage ( ContentManager content, string fileName ) : void | ||
content | ContentManager | ContentManager passed in through Game |
fileName | string | File name of XNB image in "Content" directory |
return | void |
public loadImage ( ContentManager content, string fileName, int numRows, int numCols, float anTime ) : void | ||
content | ContentManager | ContentManager passed in through Game |
fileName | string | File name of XNB image in "Content" directory |
numRows | int | Number of rows in this spritesheet |
numCols | int | Number of columns in this spritesheet |
anTime | float | Time between frames (in seconds) when animating the sprite |
return | void |
protected matchToTextureDimensions ( ) : void | ||
return | void |
public onCollide ( IInteractable other ) : void | ||
other | IInteractable | |
return | void |
protected setAnimationTime ( float time ) : void | ||
time | float | |
return | void |
public setCenter ( int x, int y ) : void | ||
x | int | X coordinate of center |
y | int | Y coordinate of center |
return | void |
public setDimensions ( int width, int height ) : void | ||
width | int | Width in pixels |
height | int | Height in pixels |
return | void |
public setImage ( Texture2D image, int numRows, int numCols, float anTime ) : void | ||
image | Texture2D | The pre-loaded image |
numRows | int | Number of rows in this spritesheet |
numCols | int | Number of columns in this spritesheet |
anTime | float | Time between frames (in seconds) when animating the sprite |
return | void |
protected setImageColumns ( int cols ) : void | ||
cols | int | |
return | void |
public setPosition ( int x, int y ) : void | ||
x | int | X coordinate of top-left corner |
y | int | Y coordinate of top-left corner |
return | void |
public setSourceRect ( int x, int y, int width, int height ) : void | ||
x | int | X coordinate of top-left corner |
y | int | Y coordinate of top-left corner |
width | int | Width in pixels |
height | int | Height in pixels |
return | void |
public update ( float elapsed ) : void | ||
elapsed | float | Time (in seconds) that has elapsed since the last update |
return | void |