C# 클래스 SunsetHigh.Sprite

Class for anything that can be drawn with a sprite. Characters and Pickups (and other drawable game components) can extend from this class to add behavior to the sprite. Alternative, just use this class for simple or static drawings.
상속: IInteractable
파일 보기 프로젝트 열기: ErraticUnicorn/MOSH 1 사용 예제들

공개 메소드들

메소드 설명
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 ( SpriteBatch sb ) : void

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.

보호된 메소드들

메소드 설명
matchToTextureDimensions ( ) : void
resetAnimation ( ) : void
setAnimationTime ( float time ) : void
setFrameColumn ( int col ) : void
setFrameRow ( int row ) : void
setImageColumns ( int cols ) : void
setImageRows ( int rows ) : void

비공개 메소드들

메소드 설명
nullCheck ( ) : void
searchDirectories ( ContentManager content, string fileName ) : Texture2D

메소드 상세

Sprite() 공개 메소드

Initializes a Sprite at the origin which will match the dimensions of its texture when the texture is loaded
public Sprite ( ) : System
리턴 System

Sprite() 공개 메소드

Initializes a Sprite at the given position. It will match the dimensions of its texture when the texture is loaded.
public Sprite ( int x, int y ) : System
x int X coordinate of top-left corner
y int Y coordinate of top-left corner
리턴 System

Sprite() 공개 메소드

Initializes a Sprite at the given position with the given dimensions
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
리턴 System

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)
public draw ( SpriteBatch sb ) : void
sb Microsoft.Xna.Framework.Graphics.SpriteBatch SpriteBatch passed in through Game
리턴 void

getAnimationTime() 공개 메소드

public getAnimationTime ( ) : float
리턴 float

getBoundingRect() 공개 메소드

public getBoundingRect ( ) : Rectangle
리턴 Rectangle

getColor() 공개 메소드

public getColor ( ) : Color
리턴 Color

getCommonImage() 공개 정적인 메소드

Retrieves a pre-loaded 2D texture to associate with an instantiated Sprite object. Good for multiple objects using the same texture
public static getCommonImage ( string imageFileName ) : Texture2D
imageFileName string The file name of the image that was previously loaded
리턴 Texture2D

getHeight() 공개 메소드

public getHeight ( ) : int
리턴 int

getImage() 공개 메소드

public getImage ( ) : Texture2D
리턴 Texture2D

getImageColumns() 공개 메소드

public getImageColumns ( ) : int
리턴 int

getImageRows() 공개 메소드

public getImageRows ( ) : int
리턴 int

getWidth() 공개 메소드

public getWidth ( ) : int
리턴 int

getX() 공개 메소드

public getX ( ) : int
리턴 int

getXCenter() 공개 메소드

public getXCenter ( ) : int
리턴 int

getY() 공개 메소드

public getY ( ) : int
리턴 int

getYCenter() 공개 메소드

public getYCenter ( ) : int
리턴 int

isVisible() 공개 메소드

public isVisible ( ) : bool
리턴 bool

loadCommonImage() 공개 정적인 메소드

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()
public static loadCommonImage ( ContentManager content, string imageFileName ) : void
content ContentManager The content manager
imageFileName string The file name of the image, without the extension
리턴 void

loadContent() 공개 메소드

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.
public loadContent ( ContentManager content ) : void
content ContentManager ContentManager passed in through Game
리턴 void

loadImage() 공개 메소드

Loads a static 2D texture with the given filename in the "Content" directory
public loadImage ( ContentManager content, string fileName ) : void
content ContentManager ContentManager passed in through Game
fileName string File name of XNB image in "Content" directory
리턴 void

loadImage() 공개 메소드

Loads a 2D spritesheet with the given filename in the "Content" directory
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
리턴 void

matchToTextureDimensions() 보호된 메소드

protected matchToTextureDimensions ( ) : void
리턴 void

onCollide() 공개 메소드

public onCollide ( IInteractable other ) : void
other IInteractable
리턴 void

onInteract() 공개 메소드

public onInteract ( ) : void
리턴 void

reset() 공개 메소드

public reset ( ) : void
리턴 void

resetAnimation() 보호된 메소드

protected resetAnimation ( ) : void
리턴 void

setAnimationTime() 보호된 메소드

protected setAnimationTime ( float time ) : void
time float
리턴 void

setCenter() 공개 메소드

Sets the position of this Sprite with given center coordinates
public setCenter ( int x, int y ) : void
x int X coordinate of center
y int Y coordinate of center
리턴 void

setColor() 공개 메소드

public setColor ( Color color ) : void
color Color
리턴 void

setDimensions() 공개 메소드

Sets the dimensions of this Sprite
public setDimensions ( int width, int height ) : void
width int Width in pixels
height int Height in pixels
리턴 void

setFrameColumn() 보호된 메소드

protected setFrameColumn ( int col ) : void
col int
리턴 void

setFrameRow() 보호된 메소드

protected setFrameRow ( int row ) : void
row int
리턴 void

setHeight() 공개 메소드

public setHeight ( int height ) : void
height int
리턴 void

setImage() 공개 메소드

Sets a static 2D texture that has already been loaded to be used to draw this Sprite
public setImage ( Texture2D image ) : void
image Texture2D
리턴 void

setImage() 공개 메소드

Sets an animating 2D texture that has already been loaded to be used to draw this Sprite
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
리턴 void

setImageColumns() 보호된 메소드

protected setImageColumns ( int cols ) : void
cols int
리턴 void

setImageRows() 보호된 메소드

protected setImageRows ( int rows ) : void
rows int
리턴 void

setPosition() 공개 메소드

Sets the position of this Sprite given the coordinates of its top-left corner
public setPosition ( int x, int y ) : void
x int X coordinate of top-left corner
y int Y coordinate of top-left corner
리턴 void

setSourceRect() 공개 메소드

Sets the source rectangle of a loaded texture for this Sprite (if the particular texture is a collection of different sprites).
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
리턴 void

setVisible() 공개 메소드

public setVisible ( bool visible ) : void
visible bool
리턴 void

setWidth() 공개 메소드

public setWidth ( int width ) : void
width int
리턴 void

setX() 공개 메소드

public setX ( int x ) : void
x int
리턴 void

setXCenter() 공개 메소드

public setXCenter ( int x ) : void
x int
리턴 void

setY() 공개 메소드

public setY ( int y ) : void
y int
리턴 void

setYCenter() 공개 메소드

public setYCenter ( int y ) : void
y int
리턴 void

unloadCommonImages() 공개 정적인 메소드

Clears memory of all loaded textures. Be sure to call unload on the ContentManager as well.
public static unloadCommonImages ( ) : void
리턴 void

update() 공개 메소드

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.
public update ( float elapsed ) : void
elapsed float Time (in seconds) that has elapsed since the last update
리턴 void