C# 클래스 flxSharp.flxSharp.FlxSprite

상속: FlxObject
파일 보기 프로젝트 열기: jlorek/flxSharp 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
Finished System.Boolean
FrameHeight float
FramePixels Microsoft.Xna.Framework.Graphics.Texture2D
FrameWidth float
Frames uint
Offset FlxPoint
Origin FlxPoint
Scale FlxPoint
moving bool

보호된 프로퍼티들

프로퍼티 타입 설명
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