Extends FlxText for better support rendering text on cpp target. Doesn't have multicamera support. Displays over all other objects.

Constructor

@:value({ EmbeddedFont : true, Size : 8 })new(X:Float, Y:Float, Width:Int, ?Text:String, Size:Int = 8, EmbeddedFont:Bool = true)

Creates a new FlxText object at the specified position.

Parameters:

X

The X position of the text.

Y

The Y position of the text.

Width

The width of the text object (height is determined automatically).

Text

The actual text you would like to display initially.

Size

The font size for this text object.

EmbeddedFont

Whether this text field uses embedded fonts or not

Methods

destroy():Void

Clean up memory.

@:access(flixel.FlxCamera)draw():Void

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

Inherited Variables

Defined by FlxText

alignment:FlxTextAlign

The alignment of the font. Note: autoSize must be set to false or alignment won't show any visual differences.

autoSize:Bool

Whether the fieldWidth and fieldHeight should be determined automatically. Requires wordWrap to be false.

bold:Bool

Whether to use bold text or not (false by default).

@:value(FlxColor.TRANSPARENT)borderColor:FlxColor = FlxColor.TRANSPARENT

The color of the border in 0xAARRGGBB format

@:value(1)borderQuality:Float = 1

How many iterations do use when drawing the border. 0: only 1 iteration, 1: one iteration for every pixel in borderSize A value of 1 will have the best quality for large border sizes, but might reduce performance when changing text. NOTE: If the borderSize is 1, borderQuality of 0 or 1 will have the exact same effect (and performance).

@:value(1)borderSize:Float = 1

The size of the border, in pixels.

@:value(NONE)borderStyle:FlxTextBorderStyle = NONE

The border style to use

read onlyembedded:Bool

Whether this text field uses an embedded font (by default) or not. Read-only - use systemFont to specify a system font to use, which then automatically sets this to false.

fieldHeight:Float

The height of TextField object used for bitmap generation for this FlxText object. Use it when you want to change the visible height of the text. Enables "auto height" if <= 0.

NOTE: Fixed height has no effect if autoSize = true.

Available since

5.4.0

.

fieldWidth:Float

The width of the TextField object used for bitmap generation for this FlxText object. Use it when you want to change the visible width of text. Enables autoSize if <= 0.

NOTE: auto width always implies auto height

font:String

The font used for this text (assuming that it's using embedded font).

italic:Bool

Whether to use italic text or not (false by default). Only works on Flash.

letterSpacing:Float

A number representing the amount of space that is uniformly distributed between all characters. The value specifies the number of pixels that are added to the advance after each character.

read onlyshadowOffset:FlxPoint

Offset that is applied to the shadow border style, if active. x and y are multiplied by borderSize. Default is (1, 1), or lower-right corner.

size:Int

The size of the text being displayed in pixels.

systemFont:String

The system font for this text (not embedded). Setting this sets embedded to false. Passing an invalid font name (like "" or null) causes a default font to be used.

@:value("")text:String = ""

The text being displayed.

read onlytextField:TextField

Reference to a TextField object used internally for rendering - be sure to know what you're doing if messing with its properties!

underline:Bool

Whether to use underlined text or not (false by default).

wordWrap:Bool

Whether to use word wrapping and multiline or not (true by default).

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 FlxText

@:value({ End : -1, Start : -1 })addFormat(Format:FlxTextFormat, Start:Int = -1, End:Int = -1):FlxText

Adds another format to this FlxText

Parameters:

Format

The format to be added.

Start

The start index of the string where the format will be applied.

End

The end index of the string where the format will be applied.

applyMarkup(input:UnicodeString, rules:Array<FlxTextFormatMarkerPair>):FlxText

Applies formats to text between marker characters, then removes those markers. NOTE: this will clear all FlxTextFormats and return to the default format.

Usage:

text.applyMarkup(
	"show $green text$ between dollar-signs",
	[new FlxTextFormatMarkerPair(greenFormat, "$")]
);

Even works for complex nested formats like this:

var yellow = new FlxTextFormatMarkerPair(yellowFormat, "@");
var green = new FlxTextFormatMarkerPair(greenFormat, "<g>");
text.applyMarkup("Hey @Buddy@, what <g>is<g> going @on<g>?<g>@", [yellow, green]);

Parameters:

input

The text you want to format

rules

FlxTextFormats to selectively apply, paired with marker strings

clearFormats():FlxText

Clears all the formats applied.

removeFormat(Format:FlxTextFormat, ?Start:Int, ?End:Int):FlxText

Removes a specific FlxTextFormat from this text. If a range is specified, this only removes the format when it touches that range.

@:value({ Quality : 1, Size : 1, Color : 0 })inlinesetBorderStyle(Style:FlxTextBorderStyle, Color:FlxColor = 0, Size:Float = 1, Quality:Float = 1):FlxText

Set border's style (shadow, outline, etc), color, and size all in one go!

Parameters:

Style

outline style

Color

outline color in 0xAARRGGBB format

Size

outline size in pixels

Quality

outline quality - # of iterations to use when drawing. 0: just 1, 1: equal number to Size

@:value({ EmbeddedFont : true, BorderColor : FlxColor.TRANSPARENT, Color : FlxColor.WHITE, Size : 8 })setFormat(?Font:String, Size:Int = 8, Color:FlxColor = FlxColor.WHITE, ?Alignment:FlxTextAlign, ?BorderStyle:FlxTextBorderStyle, BorderColor:FlxColor = FlxColor.TRANSPARENT, EmbeddedFont:Bool = true):FlxText

You can use this if you have a lot of text parameters to set instead of the individual properties.

Parameters:

Font

The name of the font face for the text display.

Size

The size of the font (in pixels essentially).

Color

The color of the text in 0xRRGGBB format.

Alignment

The desired alignment

BorderStyle

Which border style to use

BorderColor

Color for the border, 0xAARRGGBB format

EmbeddedFont

Whether this text field uses embedded fonts or not

Returns:

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

stampOnAtlas(atlas:FlxAtlas):Bool

Stamps text onto specified atlas object and loads graphic from this atlas. WARNING: Changing text after stamping it on the atlas will break the atlas, so do it only for static texts and only after making all the text customizing (like size, alignment, color, etc.)

Parameters:

atlas

atlas to stamp graphic to.

Returns:

whether the graphic was stamped on the atlas successfully

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.

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

.

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.

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({ 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.

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.

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

.