C# Class flxSharp.flxSharp.FlxSprite

Inheritance: FlxObject
Afficher le fichier Open project: jlorek/flxSharp Class Usage Examples

Méthodes publiques

Свойство Type Description
Finished System.Boolean
FrameHeight float
FramePixels Microsoft.Xna.Framework.Graphics.Texture2D
FrameWidth float
Frames uint
Offset FlxPoint
Origin FlxPoint
Scale FlxPoint
moving bool

Protected Properties

Свойство Type Description
ImgDefault Microsoft.Xna.Framework.Graphics.Texture2D
_alpha float
_animated System.Boolean
_animations List
_bakedRotation float
_callback Action
_color Color
_curAnim flxSharp.flxSharp.System.FlxAnim
_curFrame int
_curIndex int
_facing uint
_flashPoint FlxPoint
_flashPointZero FlxPoint
_flashRect FlxRect
_flashRect2 FlxRect
_flipped uint
_frameTimer float
_matrix Matrix
_pixels Microsoft.Xna.Framework.Graphics.Texture2D
camX float
camY float
drawSourceRect Microsoft.Xna.Framework.Rectangle
oX float
oY float
sourceRect FlxRect

Méthodes publiques

Méthode Description
FlxSprite ( float x, float y, Microsoft.Xna.Framework.Graphics.Texture2D graphic = null ) : System

Creates a white 8x8 square FlxSprite at the specified position. Optionally can load a simple, one-frame graphic instead.

addAnimation ( String name, int frames, float frameRate, System.Boolean looped = true ) : void

Adds a new animation to the sprite.

addAnimationCallback ( Action animationCallback ) : void

Pass in a function to be called whenever this sprite's animation changes.

centerOffsets ( bool adjustPosition = false ) : void

Helper function that adjusts the offset automatically to center the bounding box within the graphic.

destroy ( ) : void
draw ( ) : void

Called by game loop, updates then blits or renders current frame of animation to the screen

drawFrame ( bool force = false ) : void

Request (or force) that the sprite update the frame before rendering. Useful if you are doing procedural generation or other weirdness!

drawLine ( float startX, float startY, float endX, float endY, Color color, uint thickness = 1 ) : void

This function draws a line on this sprite from position X1,Y1 to position X2,Y2 with the specified color.

fill ( Color color ) : void

Fills this sprite's graphic with a specific color.

getVec2 ( ) : Vector2

flx# only

loadGraphic ( Microsoft.Xna.Framework.Graphics.Texture2D graphic, System.Boolean animated = false, System.Boolean reverse = false, float width, float height, bool unique = false ) : FlxSprite

Load an image from an embedded graphic file.

loadRotatedGraphic ( Microsoft.Xna.Framework.Graphics.Texture2D graphic, uint rotations = 16, int frame = 1, bool antiAliasing = false, bool autoBuffer = false ) : FlxSprite

Create a pre-rotated sprite sheet from a simple sprite. This can make a huge difference in graphical performance!

makeGraphic ( uint width, uint height, Color color, bool unique = false, string key = null ) : FlxSprite

This function creates a flat colored square image dynamically.

onScreen ( FlxCamera camera = null ) : bool

Check and see if this object is currently on screen. Differs from FlxObject's implementation in that it takes the actual graphic into account, not just the hitbox or bounding box or whatever.

pixelOverlapPoint ( FlxPoint point, uint mask = 0xFF, FlxCamera camera = null ) : bool

Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels. This check is ALWAYS made in screen space, and always takes scroll factors into account.

play ( String animName, System.Boolean force = false ) : void

Plays an existing animation (e.g. "run"). If you call an animation that is already playing it will be ignored.

postUpdate ( ) : void

Automatically called after update() by the game loop, this function just calls updateAnimation().

randomFrame ( ) : void

Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.

replaceColor ( Color color, Color newColor, bool fetchPositions = false ) : List

Undocumented in Flixel.

setOriginToCorner ( ) : void

Helper function that just sets origin to (0,0).

stamp ( FlxSprite brush, int x, int y ) : void

This function draws or stamps one FlxSprite onto another. This function is NOT intended to replace draw()!

Méthodes protégées

Méthode Description
calcFrame ( ) : void

Internal function to update the current animation frame.

resetHelpers ( ) : void

Resets some important variables for sprite optimization and rendering.

updateAnimation ( ) : void

Internal function for updating the sprite's animation. Useful for cases when you need to update this but are buried down in too many supers. This function is called automatically by FlxSprite.postUpdate().

Method Details

FlxSprite() public méthode

Creates a white 8x8 square FlxSprite at the specified position. Optionally can load a simple, one-frame graphic instead.
public FlxSprite ( float x, float y, Microsoft.Xna.Framework.Graphics.Texture2D graphic = null ) : System
x float The initial X position of the sprite.
y float The initial Y position of the sprite.
graphic Microsoft.Xna.Framework.Graphics.Texture2D The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!).
Résultat System

addAnimation() public méthode

Adds a new animation to the sprite.
public addAnimation ( String name, int frames, float frameRate, System.Boolean looped = true ) : void
name String What this animation should be called (e.g. "run").
frames int An array of numbers indicating what frames to play in what order (e.g. 1, 2, 3).
frameRate float The speed in frames per second that the animation should play at (e.g. 40 fps).
looped System.Boolean Whether or not the animation is looped or just plays once.
Résultat void

addAnimationCallback() public méthode

Pass in a function to be called whenever this sprite's animation changes.
public addAnimationCallback ( Action animationCallback ) : void
animationCallback Action A function that has 3 parameters: a string name, a uint frame number, and a uint frame index.
Résultat void

calcFrame() protected méthode

Internal function to update the current animation frame.
protected calcFrame ( ) : void
Résultat void

centerOffsets() public méthode

Helper function that adjusts the offset automatically to center the bounding box within the graphic.
public centerOffsets ( bool adjustPosition = false ) : void
adjustPosition bool Adjusts the actual X and Y position just once to match the offset change. Default is false.
Résultat void

destroy() public méthode

public destroy ( ) : void
Résultat void

draw() public méthode

Called by game loop, updates then blits or renders current frame of animation to the screen
public draw ( ) : void
Résultat void

drawFrame() public méthode

Request (or force) that the sprite update the frame before rendering. Useful if you are doing procedural generation or other weirdness!
public drawFrame ( bool force = false ) : void
force bool Force the frame to redraw, even if its not flagged as necessary.
Résultat void

drawLine() public méthode

This function draws a line on this sprite from position X1,Y1 to position X2,Y2 with the specified color.
public drawLine ( float startX, float startY, float endX, float endY, Color color, uint thickness = 1 ) : void
startX float X coordinate of the line's start point.
startY float Y coordinate of the line's start point.
endX float X coordinate of the line's end point.
endY float Y coordinate of the line's end point.
color Color The line's color.
thickness uint How thick the line is in pixels (default value is 1).
Résultat void

fill() public méthode

Fills this sprite's graphic with a specific color.
public fill ( Color color ) : void
color Color The color with which to fill the graphic, format 0xAARRGGBB.
Résultat void

getVec2() public méthode

flx# only
public getVec2 ( ) : Vector2
Résultat Vector2

loadGraphic() public méthode

Load an image from an embedded graphic file.
public loadGraphic ( Microsoft.Xna.Framework.Graphics.Texture2D graphic, System.Boolean animated = false, System.Boolean reverse = false, float width, float height, bool unique = false ) : FlxSprite
graphic Microsoft.Xna.Framework.Graphics.Texture2D The image you want to use.
animated System.Boolean Whether the Graphic parameter is a single sprite or a row of sprites.
reverse System.Boolean Whether you need this class to generate horizontally flipped versions of the animation frames.
width float Optional, specify the width of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).
height float Optional, specify the height of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).
unique bool Optional, whether the graphic should be a unique instance in the graphics cache. Default is false.
Résultat FlxSprite

loadRotatedGraphic() public méthode

Create a pre-rotated sprite sheet from a simple sprite. This can make a huge difference in graphical performance!
public loadRotatedGraphic ( Microsoft.Xna.Framework.Graphics.Texture2D graphic, uint rotations = 16, int frame = 1, bool antiAliasing = false, bool autoBuffer = false ) : FlxSprite
graphic Microsoft.Xna.Framework.Graphics.Texture2D The image you want to rotate and stamp.
rotations uint The number of rotation frames the final sprite should have. For small sprites this can be quite a large number (360 even) without any problems.
frame int If the Graphic has a single row of square animation frames on it, you can specify which of the frames you want to use here. Default is -1, or "use whole graphic."
antiAliasing bool Whether to use high quality rotations when creating the graphic. Default is false.
autoBuffer bool Whether to automatically increase the image size to accomodate rotated corners. Default is false. Will create frames that are 150% larger on each axis than the original frame or graphic.
Résultat FlxSprite

makeGraphic() public méthode

This function creates a flat colored square image dynamically.
public makeGraphic ( uint width, uint height, Color color, bool unique = false, string key = null ) : FlxSprite
width uint The width of the sprite you want to generate.
height uint The height of the sprite you want to generate.
color Color Specifies the color of the generated block.
unique bool Whether the graphic should be a unique instance in the graphics cache. Default is false.
key string Optional parameter - specify a string key to identify this graphic in the cache. Trumps Unique flag.
Résultat FlxSprite

onScreen() public méthode

Check and see if this object is currently on screen. Differs from FlxObject's implementation in that it takes the actual graphic into account, not just the hitbox or bounding box or whatever.
public onScreen ( FlxCamera camera = null ) : bool
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
Résultat bool

pixelOverlapPoint() public méthode

Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels. This check is ALWAYS made in screen space, and always takes scroll factors into account.
public pixelOverlapPoint ( FlxPoint point, uint mask = 0xFF, FlxCamera camera = null ) : bool
point FlxPoint The point in world space you want to check.
mask uint Used in the pixel hit test to determine what counts as solid.
camera FlxCamera Specify which game camera you want. If null getScreenXY() will just grab the first global camera.
Résultat bool

play() public méthode

Plays an existing animation (e.g. "run"). If you call an animation that is already playing it will be ignored.
public play ( String animName, System.Boolean force = false ) : void
animName String The string name of the animation you want to play.
force System.Boolean Whether to force the animation to restart.
Résultat void

postUpdate() public méthode

Automatically called after update() by the game loop, this function just calls updateAnimation().
public postUpdate ( ) : void
Résultat void

randomFrame() public méthode

Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.
public randomFrame ( ) : void
Résultat void

replaceColor() public méthode

Undocumented in Flixel.
public replaceColor ( Color color, Color newColor, bool fetchPositions = false ) : List
color Color
newColor Color
fetchPositions bool
Résultat List

resetHelpers() protected méthode

Resets some important variables for sprite optimization and rendering.
protected resetHelpers ( ) : void
Résultat void

setOriginToCorner() public méthode

Helper function that just sets origin to (0,0).
public setOriginToCorner ( ) : void
Résultat void

stamp() public méthode

This function draws or stamps one FlxSprite onto another. This function is NOT intended to replace draw()!
public stamp ( FlxSprite brush, int x, int y ) : void
brush FlxSprite The image you want to use as a brush or stamp or pen or whatever.
x int The X coordinate of the brush's top left corner on this sprite.
y int They Y coordinate of the brush's top left corner on this sprite.
Résultat void

updateAnimation() protected méthode

Internal function for updating the sprite's animation. Useful for cases when you need to update this but are buried down in too many supers. This function is called automatically by FlxSprite.postUpdate().
protected updateAnimation ( ) : void
Résultat void

Property Details

Finished public_oe property

Whether the current animation has finished its first (or only) loop.
public Boolean,System Finished
Résultat System.Boolean

FrameHeight public_oe property

The height of the actual graphic or image being displayed (not necessarily the game object/bounding box). NOTE: Edit at your own risk!! This is intended to be read-only.
public float FrameHeight
Résultat float

FramePixels public_oe property

The actual Flash BitmapData object representing the current display state of the sprite.
public Texture2D,Microsoft.Xna.Framework.Graphics FramePixels
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

FrameWidth public_oe property

The width of the actual graphic or image being displayed (not necessarily the game object/bounding box). NOTE: Edit at your own risk!! This is intended to be read-only.
public float FrameWidth
Résultat float

Frames public_oe property

The total number of frames in this image. WARNING: assumes each row in the sprite sheet is full!
public uint Frames
Résultat uint

ImgDefault protected_oe static_oe property

Default image.
protected static Texture2D,Microsoft.Xna.Framework.Graphics ImgDefault
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

Offset public_oe property

If you changed the size of your sprite object after loading or making the graphic, you might need to offset the graphic away from the bound box to center it the way you want.
public FlxPoint,flxSharp.flxSharp Offset
Résultat FlxPoint

Origin public_oe property

WARNING: The origin of the sprite will default to its center. If you change this, the visuals and the collisions will likely be pretty out-of-sync if you do any rotation.
public FlxPoint,flxSharp.flxSharp Origin
Résultat FlxPoint

Scale public_oe property

Change the size of your sprite's graphic. NOTE: Scale doesn't currently affect collisions automatically, you will need to adjust the width, height and offset manually. WARNING: scaling sprites decreases rendering performance for this sprite by a factor of 10x!
public FlxPoint,flxSharp.flxSharp Scale
Résultat FlxPoint

_alpha protected_oe property

Internal tracker for opacity, used with Flash getter/setter.
protected float _alpha
Résultat float

_animated protected_oe property

protected Boolean,System _animated
Résultat System.Boolean

_animations protected_oe property

Internal, stores all the animations that were added to this sprite.
protected List _animations
Résultat List

_bakedRotation protected_oe property

Internal tracker for how many frames of "baked" rotation there are (if any).
protected float _bakedRotation
Résultat float

_callback protected_oe property

Internal tracker for the animation callback. Default is null. If assigned, will be called each time the current frame changes. A function that has 3 parameters: a string name, a uint frame number, and a uint frame index.
protected Action _callback
Résultat Action

_color protected_oe property

Internal tracker for color tint, used with Flash getter/setter.
protected Color _color
Résultat Color

_curAnim protected_oe property

Internal, keeps track of the current animation being played.
protected FlxAnim,flxSharp.flxSharp.System _curAnim
Résultat flxSharp.flxSharp.System.FlxAnim

_curFrame protected_oe property

Internal, keeps track of the current frame of animation. This is NOT an index into the tile sheet, but the frame number in the animation object.
protected int _curFrame
Résultat int

_curIndex protected_oe property

Internal, keeps track of the current index into the tile sheet based on animation or rotation.
protected int _curIndex
Résultat int

_facing protected_oe property

Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.
protected uint _facing
Résultat uint

_flashPoint protected_oe property

Internal, reused frequently during drawing and animating.
protected FlxPoint,flxSharp.flxSharp _flashPoint
Résultat FlxPoint

_flashPointZero protected_oe property

Internal, reused frequently during drawing and animating. Always contains (0,0).
protected FlxPoint,flxSharp.flxSharp _flashPointZero
Résultat FlxPoint

_flashRect protected_oe property

Internal, reused frequently during drawing and animating.
protected FlxRect,flxSharp.flxSharp _flashRect
Résultat FlxRect

_flashRect2 protected_oe property

Internal, reused frequently during drawing and animating.
protected FlxRect,flxSharp.flxSharp _flashRect2
Résultat FlxRect

_flipped protected_oe property

Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.
protected uint _flipped
Résultat uint

_frameTimer protected_oe property

Internal, used to time each frame of animation.
protected float _frameTimer
Résultat float

_matrix protected_oe property

Internal, helps with animation, caching and drawing.
protected Matrix _matrix
Résultat Matrix

_pixels protected_oe property

Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.
protected Texture2D,Microsoft.Xna.Framework.Graphics _pixels
Résultat Microsoft.Xna.Framework.Graphics.Texture2D

camX protected_oe property

protected float camX
Résultat float

camY protected_oe property

protected float camY
Résultat float

drawSourceRect protected_oe property

protected Rectangle,Microsoft.Xna.Framework drawSourceRect
Résultat Microsoft.Xna.Framework.Rectangle

moving public_oe property

public bool moving
Résultat bool

oX protected_oe property

protected float oX
Résultat float

oY protected_oe property

protected float oY
Résultat float

sourceRect protected_oe property

protected FlxRect,flxSharp.flxSharp sourceRect
Résultat FlxRect