C# Класс flxSharp.flxSharp.FlxSprite

Наследование: FlxObject
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Finished System.Boolean
FrameHeight float
FramePixels Microsoft.Xna.Framework.Graphics.Texture2D
FrameWidth float
Frames uint
Offset FlxPoint
Origin FlxPoint
Scale FlxPoint
moving bool

Защищенные свойства (Protected)

Свойство Тип Описание
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

Открытые методы

Метод Описание
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()!

Защищенные методы

Метод Описание
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().

Описание методов

FlxSprite() публичный Метод

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!).
Результат System

addAnimation() публичный Метод

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.
Результат void

addAnimationCallback() публичный Метод

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.
Результат void

calcFrame() защищенный Метод

Internal function to update the current animation frame.
protected calcFrame ( ) : void
Результат void

centerOffsets() публичный Метод

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.
Результат void

destroy() публичный Метод

public destroy ( ) : void
Результат void

draw() публичный Метод

Called by game loop, updates then blits or renders current frame of animation to the screen
public draw ( ) : void
Результат void

drawFrame() публичный Метод

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.
Результат void

drawLine() публичный Метод

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).
Результат void

fill() публичный Метод

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.
Результат void

getVec2() публичный Метод

flx# only
public getVec2 ( ) : Vector2
Результат Vector2

loadGraphic() публичный Метод

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.
Результат FlxSprite

loadRotatedGraphic() публичный Метод

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.
Результат FlxSprite

makeGraphic() публичный Метод

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.
Результат FlxSprite

onScreen() публичный Метод

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.
Результат bool

pixelOverlapPoint() публичный Метод

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.
Результат bool

play() публичный Метод

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.
Результат void

postUpdate() публичный Метод

Automatically called after update() by the game loop, this function just calls updateAnimation().
public postUpdate ( ) : void
Результат void

randomFrame() публичный Метод

Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.
public randomFrame ( ) : void
Результат void

replaceColor() публичный Метод

Undocumented in Flixel.
public replaceColor ( Color color, Color newColor, bool fetchPositions = false ) : List
color Color
newColor Color
fetchPositions bool
Результат List

resetHelpers() защищенный Метод

Resets some important variables for sprite optimization and rendering.
protected resetHelpers ( ) : void
Результат void

setOriginToCorner() публичный Метод

Helper function that just sets origin to (0,0).
public setOriginToCorner ( ) : void
Результат void

stamp() публичный Метод

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.
Результат void

updateAnimation() защищенный Метод

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
Результат void

Описание свойств

Finished публичное свойство

Whether the current animation has finished its first (or only) loop.
public Boolean,System Finished
Результат System.Boolean

FrameHeight публичное свойство

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
Результат float

FramePixels публичное свойство

The actual Flash BitmapData object representing the current display state of the sprite.
public Texture2D,Microsoft.Xna.Framework.Graphics FramePixels
Результат Microsoft.Xna.Framework.Graphics.Texture2D

FrameWidth публичное свойство

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
Результат float

Frames публичное свойство

The total number of frames in this image. WARNING: assumes each row in the sprite sheet is full!
public uint Frames
Результат uint

ImgDefault защищенное статическое свойство

Default image.
protected static Texture2D,Microsoft.Xna.Framework.Graphics ImgDefault
Результат Microsoft.Xna.Framework.Graphics.Texture2D

Offset публичное свойство

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
Результат FlxPoint

Origin публичное свойство

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
Результат FlxPoint

Scale публичное свойство

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
Результат FlxPoint

_alpha защищенное свойство

Internal tracker for opacity, used with Flash getter/setter.
protected float _alpha
Результат float

_animated защищенное свойство

protected Boolean,System _animated
Результат System.Boolean

_animations защищенное свойство

Internal, stores all the animations that were added to this sprite.
protected List _animations
Результат List

_bakedRotation защищенное свойство

Internal tracker for how many frames of "baked" rotation there are (if any).
protected float _bakedRotation
Результат float

_callback защищенное свойство

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
Результат Action

_color защищенное свойство

Internal tracker for color tint, used with Flash getter/setter.
protected Color _color
Результат Color

_curAnim защищенное свойство

Internal, keeps track of the current animation being played.
protected FlxAnim,flxSharp.flxSharp.System _curAnim
Результат flxSharp.flxSharp.System.FlxAnim

_curFrame защищенное свойство

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
Результат int

_curIndex защищенное свойство

Internal, keeps track of the current index into the tile sheet based on animation or rotation.
protected int _curIndex
Результат int

_facing защищенное свойство

Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.
protected uint _facing
Результат uint

_flashPoint защищенное свойство

Internal, reused frequently during drawing and animating.
protected FlxPoint,flxSharp.flxSharp _flashPoint
Результат FlxPoint

_flashPointZero защищенное свойство

Internal, reused frequently during drawing and animating. Always contains (0,0).
protected FlxPoint,flxSharp.flxSharp _flashPointZero
Результат FlxPoint

_flashRect защищенное свойство

Internal, reused frequently during drawing and animating.
protected FlxRect,flxSharp.flxSharp _flashRect
Результат FlxRect

_flashRect2 защищенное свойство

Internal, reused frequently during drawing and animating.
protected FlxRect,flxSharp.flxSharp _flashRect2
Результат FlxRect

_flipped защищенное свойство

Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.
protected uint _flipped
Результат uint

_frameTimer защищенное свойство

Internal, used to time each frame of animation.
protected float _frameTimer
Результат float

_matrix защищенное свойство

Internal, helps with animation, caching and drawing.
protected Matrix _matrix
Результат Matrix

_pixels защищенное свойство

Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.
protected Texture2D,Microsoft.Xna.Framework.Graphics _pixels
Результат Microsoft.Xna.Framework.Graphics.Texture2D

camX защищенное свойство

protected float camX
Результат float

camY защищенное свойство

protected float camY
Результат float

drawSourceRect защищенное свойство

protected Rectangle,Microsoft.Xna.Framework drawSourceRect
Результат Microsoft.Xna.Framework.Rectangle

moving публичное свойство

public bool moving
Результат bool

oX защищенное свойство

protected float oX
Результат float

oY защищенное свойство

protected float oY
Результат float

sourceRect защищенное свойство

protected FlxRect,flxSharp.flxSharp sourceRect
Результат FlxRect