Constructor

new(X:Float, Y:Float, CellWidth:Float, CellHeight:Float, CellsWide:Int, CellsTall:Int, LineStyle_:LineStyle, FillColor:FlxColor)

Creates a FlxSprite with a grid drawn on top of it. X/Y is where the SPRITE is, the grid upper-left

Variables

Methods

Inherited Variables

Defined by FlxShape

@:value(false)shapeDirty:Bool = false

@:value(FlxShapeType.UNKNOWN)shape_id:FlxShapeType = FlxShapeType.UNKNOWN

Defined by FlxSprite

@:value(1.0)alpha:Float = 1.0

Set alpha to a number between 0 and 1 to change the opacity of the sprite.

See also:

animation:FlxAnimationController

Class that handles adding and playing animations on this sprite.

See also:

@:value(defaultAntialiasing)antialiasing:Bool = defaultAntialiasing

Controls whether the object is smoothed when rotated, affects performance.

@:value(0)read onlybakedRotationAngle:Float = 0

The minimum angle (out of 360°) for which a new baked rotation exists. Example: 90 means there are 4 baked rotations in the spritesheet. 0 if this sprite does not have any baked rotations.

See also:

blend:BlendMode

Blending modes, just like Photoshop or whatever, e.g. "multiply", "screen", etc.

clipRect:FlxRect

Clipping rectangle for this sprite. Changing the rect's properties directly doesn't have any effect, reassign the property to update it (sprite.clipRect = sprite.clipRect;). Set to null to discard graphic frame clipping.

@:value(0xffffff)color:FlxColor = 0xffffff

Tints the whole sprite to a color (0xRRGGBB format) - similar to OpenGL vertex colors. You can use 0xAARRGGBB colors, but the alpha value will simply be ignored. To change the opacity use alpha.

See also:

@:value(true)dirty:Bool = true

Set this flag to true to force the sprite to update during the draw() call. NOTE: Rarely if ever necessary, most sprite operations will flip this flag automatically.

@:value(RIGHT)facing:FlxDirectionFlags = RIGHT

Can be set to LEFT, RIGHT, UP, and DOWN to take advantage of flipped sprites and/or just track player orientation more easily.

See also:

@:value(false)flipX:Bool = false

Whether this sprite is flipped on the X axis.

@:value(false)flipY:Bool = false

Whether this sprite is flipped on the Y axis.

frame:FlxFrame

Link to current FlxFrame from loaded atlas

@:value(0)read onlyframeHeight:Int = 0

The height of the actual graphic or image being displayed (not necessarily the game object/bounding box).

framePixels:BitmapData

The current display state of the sprite including current animation frame, tint, flip etc... may be null unless useFramePixels is true.

@:value(0)read onlyframeWidth:Int = 0

The width of the actual graphic or image being displayed (not necessarily the game object/bounding box).

frames:FlxFramesCollection

Rendering variables.

read onlynumFrames:Int

The total number of frames in this image. WARNING: assumes each row in the sprite sheet is full!

read onlyoffset:FlxPoint

The position of the sprite's graphic relative to its hitbox. For example, offset.x = 10; will show the graphic 10 pixels left of the hitbox. Likely needs to be adjusted after changing a sprite's width, height or scale.

read onlyorigin:FlxPoint

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.

pixels:BitmapData

This sprite's graphic / BitmapData object. Automatically adjusts graphic size and render helpers if changed.

read onlyscale:FlxPoint

Change the size of your sprite's graphic. NOTE: The hitbox is not automatically adjusted, use updateHitbox() for that. WARNING: With FlxG.renderBlit, scaling sprites decreases rendering performance by a factor of about x10!

See also:

shader:FlxShader

GLSL shader for this sprite. Avoid changing it frequently as this is a costly operation.

Available since

4.1.0

.

@:value(false)read onlyuseColorTransform:Bool = false

Whether or not to use a ColorTransform set via setColorTransform().

@:value(true)useFramePixels:Bool = true

Always true on FlxG.renderBlit. On FlxG.renderTile it determines whether framePixels is used and defaults to false for performance reasons.

Defined by FlxObject

read onlyacceleration:FlxPoint

How fast the speed of this object is changing (in pixels per second). Useful for smooth movement and gravity.

@:value(FlxDirectionFlags.ANY)allowCollisions:FlxDirectionFlags = FlxDirectionFlags.ANY

Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions. Use bitwise operators to check the values stored here. Useful for things like one-way platforms (e.g. allowCollisions = UP;). The accessor "solid" just flips this variable between NONE and ANY.

@:value(0)angle:Float = 0

Set the angle (in degrees) of a sprite to rotate it. WARNING: rotating sprites decreases their rendering performance by a factor of ~10x when using blitting!

@:value(0)angularAcceleration:Float = 0

How fast the spin speed should change (in degrees per second).

@:value(0)angularDrag:Float = 0

Like drag but for spinning.

@:value(0)angularVelocity:Float = 0

This is how fast you want this sprite to spin (in degrees per second).

@:value(IMMOVABLE)collisionXDrag:CollisionDragType = IMMOVABLE

Whether this sprite is dragged along with the horizontal movement of objects it collides with (makes sense for horizontally-moving platforms in platformers for example). Use values IMMOVABLE, ALWAYS, HEAVIER or NEVER

Available since

4.11.0

.

@:value(NEVER)collisionYDrag:CollisionDragType = NEVER

Whether this sprite is dragged along with the vertical movement of objects it collides with (for sticking to vertically-moving platforms in platformers for example). Use values IMMOVABLE, ALWAYS, HEAVIER or NEVER

Available since

4.11.0

.

collisonXDrag:Bool

Deprecated: "Use `collisionXDrag`, instead. Note the corrected spelling: `collis(i)onXDrag"

DEPRECATED Whether this sprite is dragged along with the horizontal movement of objects it collides with (makes sense for horizontally-moving platforms in platformers for example).

Apart from having a weird typo, this has been deprecated for collisionXDrag, which allows more options.

@:value(null)debugBoundingBoxColor:Null<FlxColor> = null

Overriding this will force a specific color to be used for debug rect (ignoring any of the other debug bounding box colors specified).

@:value(FlxColor.BLUE)debugBoundingBoxColorNotSolid:FlxColor = FlxColor.BLUE

Color used for the debug rect if allowCollisions == NONE.

Available since

4.2.0

.

@:value(FlxColor.GREEN)debugBoundingBoxColorPartial:FlxColor = FlxColor.GREEN

Color used for the debug rect if this object collides partially (immovable in the case of FlxObject, or allowCollisions not equal to ANY or NONE in the case of tiles in FlxTilemap).

Available since

4.2.0

.

@:value(FlxColor.RED)debugBoundingBoxColorSolid:FlxColor = FlxColor.RED

Color used for the debug rect if allowCollisions == ANY.

Available since

4.2.0

.

read onlydrag:FlxPoint

This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.

@:value(0)elasticity:Float = 0

The bounciness of this object. Only affects collisions. Default value is 0, or "not bouncy at all."

@:value(1)health:Float = 1

Deprecated: "object.health is being removed in version 6.0.0"

Handy for storing health percentage or armor points or whatever.

@:isVarheight:Float

The height of this object's hitbox. For sprites, use offset to control the hitbox position.

@:value(false)ignoreDrawDebug:Bool = false

Setting this to true will prevent the object's bounding box from appearing when FlxG.debugger.drawDebug is true.

@:value(false)immovable:Bool = false

Whether an object will move/alter position after a collision.

read onlylast:FlxPoint

Important variable for collision processing. By default this value is set automatically during at the start of update().

@:value(1)mass:Float = 1

The virtual mass of the object. Default value is 1. Currently only used with elasticity during collision resolution. Change at your own risk; effects seem crazy unpredictable so far!

@:value(10000)maxAngular:Float = 10000

Use in conjunction with angularAcceleration for fluid spin speed control.

read onlymaxVelocity:FlxPoint

If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).

@:value(defaultMoves)moves:Bool = defaultMoves

Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()). FlxObject and FlxSprite default to true. FlxText, FlxTileblock and FlxTilemap default to false.

@:value(null)path:FlxPath = null

The path this object follows. Not initialized by default. Assign a new FlxPath() object and start() it if you want to this object to follow a path. Set path to null again to stop following the path. See flixel.util.FlxPath for more info and usage examples.

@:value(true)pixelPerfectPosition:Bool = true

Whether or not the position of this object should be rounded before any draw() or collision checking.

pixelPerfectRender:Null<Bool>

Whether or not the coordinates should be rounded during rendering. Does not affect copyPixels(), which can only render on whole pixels. Defaults to the camera's global pixelPerfectRender value, but overrides that value if not equal to null.

read onlyscrollFactor:FlxPoint

Controls how much this object is affected by camera scrolling. 0 = no movement (e.g. a background layer), 1 = same movement speed as the foreground. Default value is (1,1), except for UI elements like FlxButton where it's (0,0).

solid:Bool

Whether the object collides or not. For more control over what directions the object will collide from, use collision constants (like LEFT, FLOOR, etc) to set the value of allowCollisions directly.

@:value(FlxDirectionFlags.NONE)touching:FlxDirectionFlags = FlxDirectionFlags.NONE

Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts. Use bitwise operators to check the values stored here, or use isTouching(), justTouched(), etc. You can even use them broadly as boolean values if you're feeling saucy!

read onlyvelocity:FlxPoint

The basic speed of this object (in pixels per second).

@:value(FlxDirectionFlags.NONE)wasTouching:FlxDirectionFlags = FlxDirectionFlags.NONE

Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step. Use bitwise operators to check the values stored here, or use isTouching(), justTouched(), etc. You can even use them broadly as boolean values if you're feeling saucy!

@:isVarwidth:Float

The width of this object's hitbox. For sprites, use offset to control the hitbox position.

@:value(0)x:Float = 0

X position of the upper left corner of this object in world space.

@:value(0)y:Float = 0

Y position of the upper left corner of this object in world space.

Defined by FlxBasic

@:value(idEnumerator++)ID:Int = idEnumerator++

A unique ID starting from 0 and increasing by 1 for each subsequent FlxBasic that is created.

@:value(true)active:Bool = true

Controls whether update() is automatically called by FlxState/FlxGroup.

@:value(true)alive:Bool = true

Useful state for many game objects - "dead" (!alive) vs alive. kill() and revive() both flip this switch (along with exists, but you can override that).

camera:FlxCamera

Gets or sets the first camera of this object.

cameras:Array<FlxCamera>

This determines on which FlxCameras this object will be drawn. If it is null / has not been set, it uses the list of default draw targets, which is controlled via FlxG.camera.setDefaultDrawTarget as well as the DefaultDrawTarget argument of FlxG.camera.add.

read onlycontainer:Null<FlxContainer>

The parent containing this basic, typically if you check this recursively you should reach the state

Available since

5.7.0

.

@:value(true)exists:Bool = true

Controls whether update() and draw() are automatically called by FlxState/FlxGroup.

@:value(true)visible:Bool = true

Controls whether draw() is automatically called by FlxState/FlxGroup.

Inherited Methods

Defined by FlxShapeBox

Defined by FlxShape

Defined by FlxSprite

@:value({ AdjustPosition : false })centerOffsets(AdjustPosition:Bool = false):Void

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

Parameters:

AdjustPosition

Adjusts the actual X and Y position just once to match the offset change.

inlinecenterOrigin():Void

Sets the sprite's origin to its center - useful after adjusting scale to make sure rotations work as expected.

@:value({ Force : false })drawFrame(Force:Bool = false):Void

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

Parameters:

Force

Force the frame to redraw, even if its not flagged as necessary.

getGraphicMidpoint(?point:FlxPoint):FlxPoint

Retrieve the midpoint of this sprite's graphic in world coordinates.

Parameters:

point

Allows you to pass in an existing FlxPoint if you're so inclined. Otherwise a new one is created.

Returns:

A FlxPoint containing the midpoint of this sprite's graphic in world coordinates.

getPixelAt(worldPoint:FlxPoint, ?camera:FlxCamera):Null<FlxColor>

Determines which of this sprite's pixels are at the specified world coordinate, if any. Factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

worldPoint

The point in world space

camera

The camera, used for scrollFactor. If null, FlxG.camera is used.

Returns:

a FlxColor, if the point is in the sprite's graphic, otherwise null is returned.

Available since

5.0.0

.

getPixelAtScreen(screenPoint:FlxPoint, ?camera:FlxCamera):Null<FlxColor>

Determines which of this sprite's pixels are at the specified screen coordinate, if any. Factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

screenPoint

The point in screen space

camera

The desired "screen" coordinate space. If null, FlxG.camera is used.

Returns:

a FlxColor, if the point is in the sprite's graphic, otherwise null is returned.

Available since

5.0.0

.

getRotatedBounds(?newRect:FlxRect):FlxRect

Calculates the smallest globally aligned bounding box that encompasses this sprite's width and height, at its current rotation. Note, if called on a FlxSprite, the origin is used, but scale and offset are ignored. Use getScreenBounds to use these properties.

Parameters:

newRect

The optional output FlxRect to be returned, if null, a new one is created.

Returns:

A globally aligned FlxRect that fully contains the input object's width and height.

Available since

4.11.0

.

getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect

Calculates the smallest globally aligned bounding box that encompasses this sprite's graphic as it would be displayed. Honors scrollFactor, rotation, scale, offset and origin.

Parameters:

newRect

Optional output FlxRect, if null, a new one is created.

camera

Optional camera used for scrollFactor, if null FlxG.camera is used.

Returns:

A globally aligned FlxRect that fully contains the input sprite.

Available since

4.11.0

.

graphicLoaded():Void

Called whenever a new graphic is loaded for this sprite (after loadGraphic(), makeGraphic() etc).

isOnScreen(?camera:FlxCamera):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.

Parameters:

Camera

Specify which game camera you want. If null, FlxG.camera is used.

Returns:

Whether the object is on screen or not.

isSimpleRender(?camera:FlxCamera):Bool

Returns the result of isSimpleRenderBlit() if FlxG.renderBlit is true, or false if FlxG.renderTile is true.

isSimpleRenderBlit(?camera:FlxCamera):Bool

Determines the function used for rendering in blitting: copyPixels() for simple sprites, draw() for complex ones. Sprites are considered simple when they have an angle of 0, a scale of 1, don't use blend and pixelPerfectRender is true.

Parameters:

camera

If a camera is passed its pixelPerfectRender flag is taken into account

@:value({ unique : false, frameHeight : 0, frameWidth : 0, animated : false })loadGraphic(graphic:FlxGraphicAsset, animated:Bool = false, frameWidth:Int = 0, frameHeight:Int = 0, unique:Bool = false, ?key:String):FlxSprite

Load an image from an embedded graphic file.

HaxeFlixel's graphic caching system keeps track of loaded image data. When you load an identical copy of a previously used image, by default HaxeFlixel copies the previous reference onto the pixels field instead of creating another copy of the image data, to save memory.

NOTE: This method updates hitbox size and frame size.

Parameters:

graphic

The image you want to use.

animated

Whether the Graphic parameter is a single sprite or a row / grid of sprites.

frameWidth

Specify the width of your sprite (helps figure out what to do with non-square sprites or sprite sheets).

frameHeight

Specify the height of your sprite (helps figure out what to do with non-square sprites or sprite sheets).

unique

Whether the graphic should be a unique instance in the graphics cache. Set this to true if you want to modify the pixels field without changing the pixels of other sprites with the same BitmapData.

key

Set this parameter if you're loading BitmapData.

Returns:

This FlxSprite instance (nice for chaining stuff together, if you're into that).

loadGraphicFromSprite(Sprite:FlxSprite):FlxSprite

Load graphic from another FlxSprite and copy its tile sheet data. This method can useful for non-flash targets.

Parameters:

Sprite

The FlxSprite from which you want to load graphic data.

Returns:

This FlxSprite instance (nice for chaining stuff together, if you're into that).

@:value({ AutoBuffer : false, AntiAliasing : false, Rotations : 16 })loadRotatedFrame(Frame:FlxFrame, Rotations:Int = 16, AntiAliasing:Bool = false, AutoBuffer:Bool = false):FlxSprite

Helper method which allows using FlxFrame as graphic source for sprite's loadRotatedGraphic() method.

Parameters:

frame

Frame to load into this sprite.

rotations

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.

antiAliasing

Whether to use high quality rotations when creating the graphic. Default is false.

autoBuffer

Whether to automatically increase the image size to accommodate rotated corners. Will create frames that are 150% larger on each axis than the original frame or graphic.

Returns:

this FlxSprite with loaded rotated graphic in it.

@:value({ AutoBuffer : false, AntiAliasing : false, Frame : -1, Rotations : 16 })loadRotatedGraphic(Graphic:FlxGraphicAsset, Rotations:Int = 16, Frame:Int = -1, AntiAliasing:Bool = false, AutoBuffer:Bool = false, ?Key:String):FlxSprite

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

Parameters:

Graphic

The image you want to rotate and stamp.

Rotations

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

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

Whether to use high quality rotations when creating the graphic. Default is false.

AutoBuffer

Whether to automatically increase the image size to accommodate rotated corners. Will create frames that are 150% larger on each axis than the original frame or graphic.

Key

Optional, set this parameter if you're loading BitmapData.

Returns:

This FlxSprite instance (nice for chaining stuff together, if you're into that).

@:value({ Unique : false, Color : FlxColor.WHITE })makeGraphic(Width:Int, Height:Int, Color:FlxColor = FlxColor.WHITE, Unique:Bool = false, ?Key:String):FlxSprite

This function creates a flat colored rectangular image dynamically.

HaxeFlixel's graphic caching system keeps track of loaded image data. When you make an identical copy of a previously used image, by default HaxeFlixel copies the previous reference onto the pixels field instead of creating another copy of the image data, to save memory.

NOTE: This method updates hitbox size and frame size.

Parameters:

Width

The width of the sprite you want to generate.

Height

The height of the sprite you want to generate.

Color

Specifies the color of the generated block (ARGB format).

Unique

Whether the graphic should be a unique instance in the graphics cache. Default is false. Set this to true if you want to modify the pixels field without changing the pixels of other sprites with the same BitmapData.

Key

An optional String key to identify this graphic in the cache. If null, the key is determined by Width, Height and Color. If Unique is true and a graphic with this Key already exists, it is used as a prefix to find a new unique name like "Key3".

Returns:

This FlxSprite instance (nice for chaining stuff together, if you're into that).

@:value({ alphaTolerance : 0xFF })pixelsOverlapPoint(worldPoint:FlxPoint, alphaTolerance:Int = 0xFF, ?camera:FlxCamera):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 factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

worldPoint

point in world space you want to check.

alphaTolerance

Used to determine what counts as solid.

camera

The desired "screen" coordinate space. If null, FlxG.camera is used.

Returns:

Whether or not the point overlaps this object.

@:value({ FetchPositions : false })replaceColor(Color:FlxColor, NewColor:FlxColor, FetchPositions:Bool = false):Array<FlxPoint>

Replaces all pixels with specified Color with NewColor pixels. WARNING: very expensive (especially on big graphics) as it iterates over every single pixel.

Parameters:

Color

Color to replace

NewColor

New color

FetchPositions

Whether we need to store positions of pixels which colors were replaced.

Returns:

Array with replaced pixels positions

inlineresetFrame():Void

Helper method just for convenience, so you don't need to type sprite.frame = sprite.frame; You may need this method in tile render mode, when you want sprite to use its original graphic, not the graphic generated from its framePixels.

inlineresetFrameSize():Void

Resets frame size to frame dimensions.

inlineresetSize():Void

Resets some internal variables used for frame BitmapData calculation.

inlineresetSizeFromFrame():Void

Resets sprite's size back to frame size.

@:value({ alphaOffset : 0.0, blueOffset : 0.0, greenOffset : 0.0, redOffset : 0.0, alphaMultiplier : 1.0, blueMultiplier : 1.0, greenMultiplier : 1.0, redMultiplier : 1.0 })setColorTransform(redMultiplier:Float = 1.0, greenMultiplier:Float = 1.0, blueMultiplier:Float = 1.0, alphaMultiplier:Float = 1.0, redOffset:Float = 0.0, greenOffset:Float = 0.0, blueOffset:Float = 0.0, alphaOffset:Float = 0.0):Void

Sets the sprite's color transformation with control over color offsets. With FlxG.renderTile, offsets are only supported on OpenFL Next version 3.6.0 or higher.

Parameters:

redMultiplier

The value for the red multiplier, in the range from 0 to 1.

greenMultiplier

The value for the green multiplier, in the range from 0 to 1.

blueMultiplier

The value for the blue multiplier, in the range from 0 to 1.

alphaMultiplier

The value for the alpha transparency multiplier, in the range from 0 to 1.

redOffset

The offset value for the red color channel, in the range from -255 to 255.

greenOffset

The offset value for the green color channel, in the range from -255 to 255.

blueOffset

The offset for the blue color channel value, in the range from -255 to 255.

alphaOffset

The offset for alpha transparency channel value, in the range from -255 to 255.

inlinesetFacingFlip(Direction:FlxDirectionFlags, FlipX:Bool, FlipY:Bool):Void

Set how a sprite flips when facing in a particular direction.

Parameters:

Direction

Use constants LEFT, RIGHT, UP, and DOWN. These may be combined with the bitwise OR operator. E.g. To make a sprite flip horizontally when it is facing both UP and LEFT, use setFacingFlip(LEFT | UP, true, false);

FlipX

Whether to flip the sprite on the X axis.

FlipY

Whether to flip the sprite on the Y axis.

@:value({ saveAnimations : true })@:access(flixel.animation.FlxAnimationController)setFrames(Frames:FlxFramesCollection, saveAnimations:Bool = true):FlxSprite

Sets frames and allows you to save animations in sprite's animation controller

Parameters:

Frames

Frames collection to set for this sprite.

saveAnimations

Whether to save animations in animation controller or not.

Returns:

This sprite with loaded frames

@:value({ height : 0.0, width : 0.0 })setGraphicSize(width:Float = 0.0, height:Float = 0.0):Void

Helper function to set the graphic's dimensions by using scale, allowing you to keep the current aspect ratio should one of the numbers be <= 0. It might make sense to call updateHitbox() afterwards!

Parameters:

width

How wide the graphic should be. If <= 0, and height is set, the aspect ratio will be kept.

height

How high the graphic should be. If <= 0, and width is set, the aspect ratio will be kept.

@:value({ Y : 0, X : 0 })stamp(Brush:FlxSprite, X:Int = 0, Y:Int = 0):Void

Stamps / draws another FlxSprite onto this FlxSprite. This function is NOT intended to replace draw()!

Parameters:

Brush

The sprite you want to use as a brush or stamp or pen or whatever.

X

The X coordinate of the brush's top left corner on this sprite.

Y

They Y coordinate of the brush's top left corner on this sprite.

transformScreenToPixels(screenPoint:FlxPoint, ?camera:FlxCamera, ?result:FlxPoint):FlxPoint

Converts the point from screen coordinates to this sprite's pixel coordinates where (0,0) is the top left of the graphic. Factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

screenPoint

The screen coordinates

camera

The desired "screen" coordinate space. If null, FlxG.camera is used.

result

Optional arg for the returning point

transformWorldToPixels(worldPoint:FlxPoint, ?camera:FlxCamera, ?result:FlxPoint):FlxPoint

Converts the point from world coordinates to this sprite's pixel coordinates where (0,0) is the top left of the graphic. Factors in scale, angle, offset, origin, and scrollFactor.

Parameters:

worldPoint

The world coordinates.

camera

The camera, used for scrollFactor. If null, FlxG.camera is used.

result

Optional arg for the returning point

transformWorldToPixelsSimple(worldPoint:FlxPoint, ?result:FlxPoint):FlxPoint

Converts the point from world coordinates to this sprite's pixel coordinates where (0,0) is the top left of the graphic. Same as worldToPixels but never uses a camera, therefore scrollFactor is ignored

Parameters:

worldPoint

The world coordinates.

result

Optional arg for the returning point

updateFramePixels():BitmapData

Retrieves the BitmapData of the current FlxFrame. Updates framePixels.

updateHitbox():Void

Updates the sprite's hitbox (width, height, offset) according to the current scale. Also calls centerOrigin().

Defined by FlxObject

drawDebugOnCamera(camera:FlxCamera):Void

Override this function to draw custom "debug mode" graphics to the specified camera while the debugger's drawDebug mode is toggled on.

Parameters:

Camera

Which camera to draw the debug visuals to.

getMidpoint(?point:FlxPoint):FlxPoint

Retrieve the midpoint of this object in world coordinates.

Parameters:

point

Allows you to pass in an existing FlxPoint object if you're so inclined. Otherwise a new one is created.

Returns:

A FlxPoint object containing the midpoint of this object in world coordinates.

getPosition(?result:FlxPoint):FlxPoint

Returns the world position of this object.

Parameters:

result

Optional arg for the returning point.

Returns:

The world position of this object.

getScreenPosition(?result:FlxPoint, ?camera:FlxCamera):FlxPoint

Returns the screen position of this object.

Parameters:

result

Optional arg for the returning point

camera

The desired "screen" coordinate space. If null, FlxG.camera is used.

Returns:

The screen position of this object.

hurt(damage:Float):Void

Deprecated: "object.health is being removed in version 6.0.0"

Reduces the health variable of this object by the amount specified in Damage. Calls kill() if health drops to or below zero.

Parameters:

Damage

How much health to take away (use a negative number to give a health bonus).

inlineinWorldBounds():Bool

Check and see if this object is currently within the world bounds - useful for killing objects that get too far away.

Returns:

Whether the object is within the world bounds or not.

isPixelPerfectRender(?camera:FlxCamera):Bool

Check if object is rendered pixel perfect on a specific camera.

inlineisTouching(direction:FlxDirectionFlags):Bool

Handy function for checking if this object is touching a particular surface. Note: These flags are set from FlxG.collide calls, and get reset in super.update().

Parameters:

direction

Any of the collision flags (e.g. LEFT, FLOOR, etc).

Returns:

Whether the object is touching an object in (any of) the specified direction(s) this frame.

inlinejustTouched(direction:FlxDirectionFlags):Bool

Handy function for checking if this object is just landed on a particular surface. Note: These flags are set from FlxG.collide calls, and get reset in super.update().

Parameters:

direction

Any of the collision flags (e.g. LEFT, FLOOR, etc).

Returns:

Whether the object just landed on (any of) the specified surface(s) this frame.

@:value({ inScreenSpace : false })@:access(flixel.group.FlxTypedGroup)overlaps(objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool

Checks to see if some FlxObject overlaps this FlxObject or FlxGroup. If the group has a LOT of things in it, it might be faster to use FlxG.overlap(). WARNING: Currently tilemaps do NOT support screen space overlap checks!

Parameters:

objectOrGroup

The object or group being tested.

inScreenSpace

Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space."

camera

Specify which game camera you want. If null, it will just grab the first global camera.

Returns:

Whether or not the two objects overlap.

@:value({ inScreenSpace : false })@:access(flixel.group.FlxTypedGroup)overlapsAt(x:Float, y:Float, objectOrGroup:FlxBasic, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool

Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account. WARNING: Currently tilemaps do NOT support screen space overlap checks!

Parameters:

x

The X position you want to check. Pretends this object (the caller, not the parameter) is located here.

y

The Y position you want to check. Pretends this object (the caller, not the parameter) is located here.

objectOrGroup

The object or group being tested.

inScreenSpace

Whether to take scroll factors into account when checking for overlap. Default is false, or "only compare in world space."

camera

Specify which game camera you want. If null, it will just grab the first global camera.

Returns:

Whether or not the two objects overlap.

@:value({ inScreenSpace : false })overlapsPoint(point:FlxPoint, inScreenSpace:Bool = false, ?camera:FlxCamera):Bool

Checks to see if a point in 2D world space overlaps this FlxObject.

Parameters:

point

The point in world space you want to check.

inScreenSpace

Whether to take scroll factors into account when checking for overlap.

camera

Specify which game camera you want. If null, it will just grab the first global camera.

Returns:

Whether or not the point overlaps this object.

reset(x:Float, y:Float):Void

Handy function for reviving game objects. Resets their existence flags and position.

Parameters:

x

The new X position of this object.

y

The new Y position of this object.

@:value({ axes : XY })inlinescreenCenter(axes:FlxAxes = XY):FlxObject

Centers this FlxObject on the screen, either by the x axis, y axis, or both.

Parameters:

axes

On what axes to center the object (e.g. X, Y, XY) - default is both.

Returns:

This FlxObject for chaining

@:value({ y : 0.0, x : 0.0 })setPosition(x:Float = 0.0, y:Float = 0.0):Void

Helper function to set the coordinates of this object. Handy since it only requires one line of code.

Parameters:

x

The new x position

y

The new y position

setSize(width:Float, height:Float):Void

Shortcut for setting both width and Height.

Parameters:

width

The new hitbox width.

height

The new hitbox height.

toString():String

Convert object to readable string name. Useful for debugging, save games, etc.

Defined by FlxBasic

getCameras():Array<FlxCamera>

The cameras that will draw this. Use this.cameras to set specific cameras for this object, otherwise the container's cameras are used, or the container's container and so on. If there is no container, say, if this is inside FlxGroups rather than a FlxContainer then the default draw cameras are returned.

Available since

5.7.0

.

kill():Void

Handy function for "killing" game objects. Use reset() to revive them. Default behavior is to flag them as nonexistent AND dead. However, if you want the "corpse" to remain in the game, like to animate an effect or whatever, you should override this, setting only alive to false, and leaving exists true.

revive():Void

Handy function for bringing game objects "back to life". Just sets alive and exists back to true. In practice, this function is most often called by FlxObject#reset().