A slider GUI element for float and integer manipulation. @author Gama11

Constructor

@:value({ HandleColor : 0xFF828282, Color : 0xFF000000, Thickness : 3, Height : 15, Width : 100, MaxValue : 10, MinValue : 0, Y : 0, X : 0 })new(Object:Dynamic, VarString:String, X:Float = 0, Y:Float = 0, MinValue:Float = 0, MaxValue:Float = 10, Width:Int = 100, Height:Int = 15, Thickness:Int = 3, Color:Int = 0xFF000000, HandleColor:Int = 0xFF828282)

Creates a new FlxSlider.

Parameters:

Object

Reference to the parent object of the variable

VarString

Variable that the slider controls

X

x Position

Y

y Position

MinValue

Mininum value the variable can be changed to

MaxValue

Maximum value the variable can be changed to

Width

Width of the slider

Height

Height of the slider

Thickness

Thickness of the slider

Color

Color of the slider background and all texts except for valueText showing the current value

HandleColor

Color of the slider handle and the valueText showing the current value

Variables

body:FlxSprite

The horizontal line in the background.

clickSound:String

Sound that's played whenever the slider is clicked.

@:value(0)decimals:Int = 0

How many decimals the variable can have at max. Default is zero, or "only whole numbers".

read onlyexpectedPos:Float

The expected position of the handle based on the current variable value.

handle:FlxSprite

The dragable handle - loadGraphic() to change its graphic.

@:value(0.5)hoverAlpha:Float = 0.5

The alpha value the slider uses when it's hovered over. 1 to turn the effect off.

hoverSound:String

Sound that's played whenever the slider is hovered over.

maxLabel:FlxText

The text under the right border - equals maxValue by default.

maxValue:Float

Maximum value the variable can be changed to.

minLabel:FlxText

The text under the left border - equals minValue by default.

minValue:Float

Mininum value the variable can be changed to.

nameLabel:FlxText

A text above the slider that displays its name.

read onlyrelativePos:Float

The position of the handle relative to the slider / max value.

@:value(true)setVariable:Bool = true

Whether the slider sets the variable it tracks. Can be useful to deactivate this in conjunction with callbacks.

value:Float

Stores the current value of the variable - updated each frame.

valueLabel:FlxText

A text under the slider that displays the current value.

varString:String

Stores the variable the slider controls.

@:value(null)callback:Float‑>Void = null

A function to be called when the slider was used. The current relativePos is passed as an argument.

Methods

destroy():Void

Cleaning up memory.

@:value({ Size : 8, Value : true })setTexts(Name:String, Value:Bool = true, ?Min:String, ?Max:String, Size:Int = 8):Void

Handy function for changing the textfields.

Parameters:

Name

Text of nameLabel - null to hide

Value

Whether to show the valueText or not

Min

Text of minLabel - null to hide

Max

Text of maxLabel - null to hide

Size

Size to use for the texts

Inherited Variables

Defined by FlxTypedSpriteGroup

@:value(false)directAlpha:Bool = false

Whether to attempt to preserve the ratio of alpha values of group members, or set them directly through the alpha property. Defaults to false (preservation).

Available since

4.5.0

.

group:FlxTypedGroup<T>

The actual group which holds all sprites.

read onlylength:Int

The number of entries in the members array. For performance and safety you should check this variable instead of members.length unless you really know what you're doing!

maxSize:Int

The maximum capacity of this group. Default is 0, meaning no max capacity, and the group can just grow.

read onlymembers:Array<T>

The link to a group's members array.

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.

animation:FlxAnimationController

Class that handles adding and playing animations on this sprite.

@:value(false)antialiasing:Bool = false

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.

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.

@: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(FlxObject.RIGHT)facing:Int = FlxObject.RIGHT

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

@: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.

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

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

read onlyoffset:FlxPoint

Controls the position of the sprite's 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 (or setGraphicSize()). WARNING: With FlxG.renderBlit, scaling sprites decreases rendering performance by a factor of about x10!

shader:FlxShader

GLSL shader for this sprite. Only works with OpenFL Next or WebGL. 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(ANY)allowCollisions:Int = 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(true)collisonXDrag:Bool = true

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).

@: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 == FlxObject.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 FlxObject.ANY or FlxObject.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 == FlxObject.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

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 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(true)moves:Bool = true

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(NONE)touching:Int = 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(NONE)wasTouching:Int = 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(-1)ID:Int = -1

IDs seem like they could be pretty useful, huh? They're not actually used for anything yet though.

@: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 ot 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 FlxCamera.defaultCameras, which is a reference to FlxG.cameras.list (all cameras) by default.

@: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 FlxTypedSpriteGroup

add(Sprite:T):T

Adds a new FlxSprite subclass to the group.

Parameters:

Sprite

The sprite or sprite group you want to add to the group.

Returns:

The same object that was passed in.

inlineclear():Void

Remove all instances of FlxSprite from the list. WARNING: does not destroy() or kill() any of these objects!

clone():FlxTypedSpriteGroup<T>

Recursive cloning method: it will create a copy of this group which will hold copies of all sprites

Returns:

copy of this sprite group

inlinecountDead():Int

Call this function to find out how many members of the group are dead.

Returns:

The number of FlxSprites flagged as dead. Returns -1 if group is empty.

inlinecountLiving():Int

Call this function to find out how many members of the group are not dead.

Returns:

The number of FlxSprites flagged as not dead. Returns -1 if group is empty.

@:value({ Recurse : false })inlineforEach(Function:T‑>Void, Recurse:Bool = false):Void

Applies a function to all members.

Parameters:

Function

A function that modifies one element at a time.

Recurse

Whether or not to apply the function to members of subgroups as well.

@:value({ Recurse : false })inlineforEachAlive(Function:T‑>Void, Recurse:Bool = false):Void

Applies a function to all alive members.

Parameters:

Function

A function that modifies one element at a time.

Recurse

Whether or not to apply the function to members of subgroups as well.

@:value({ Recurse : false })inlineforEachDead(Function:T‑>Void, Recurse:Bool = false):Void

Applies a function to all dead members.

Parameters:

Function

A function that modifies one element at a time.

Recurse

Whether or not to apply the function to members of subgroups as well.

@:value({ Recurse : false })inlineforEachExists(Function:T‑>Void, Recurse:Bool = false):Void

Applies a function to all existing members.

Parameters:

Function

A function that modifies one element at a time.

Recurse

Whether or not to apply the function to members of subgroups as well.

@:value({ Recurse : false })inlineforEachOfType<K>(ObjectClass:Class<K>, Function:K‑>Void, Recurse:Bool = false):Void

Applies a function to all members of type Class<K>.

Parameters:

ObjectClass

A class that objects will be checked against before Function is applied, ex: FlxSprite.

Function

A function that modifies one element at a time.

Recurse

Whether or not to apply the function to members of subgroups as well.

inlinegetFirstAlive():T

Call this function to retrieve the first object with dead == false in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.

Returns:

A FlxSprite currently flagged as not dead.

@:value({ Force : false })inlinegetFirstAvailable(?ObjectClass:Class<T>, Force:Bool = false):T

Call this function to retrieve the first object with exists == false in the group. This is handy for recycling in general, e.g. respawning enemies.

Parameters:

ObjectClass

An optional parameter that lets you narrow the results to instances of this particular class.

Force

Force the object to be an ObjectClass and not a super class of ObjectClass.

Returns:

A FlxSprite currently flagged as not existing.

inlinegetFirstDead():T

Call this function to retrieve the first object with dead == true in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.

Returns:

A FlxSprite currently flagged as dead.

inlinegetFirstExisting():T

Call this function to retrieve the first object with exists == true in the group. This is handy for checking if everything's wiped out, or choosing a squad leader, etc.

Returns:

A FlxSprite currently flagged as existing.

inlinegetFirstNull():Int

Call this function to retrieve the first index set to null. Returns -1 if no index stores a null object.

Returns:

An Int indicating the first null slot in the group.

@:value({ Length : 0, StartIndex : 0 })inlinegetRandom(StartIndex:Int = 0, Length:Int = 0):T

Returns a member at random from the group.

Parameters:

StartIndex

Optional offset off the front of the array. Default value is 0, or the beginning of the array.

Length

Optional restriction on the number of values you want to randomly select from.

Returns:

A FlxSprite from the members list.

insert(Position:Int, Sprite:T):T

Inserts a new FlxSprite subclass to the group at the specified position.

Parameters:

Position

The position that the new sprite or sprite group should be inserted at.

Sprite

The sprite or sprite group you want to insert into the group.

Returns:

The same object that was passed in.

Available since

4.3.0

.

isOnScreen(?Camera:FlxCamera):Bool

Check and see if any sprite in this group is currently on screen.

Parameters:

Camera

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

Returns:

Whether the object is on screen or not.

inlineiterator(?filter:T‑>Bool):FlxTypedGroupIterator<T>

Iterate through every member

Returns:

An iterator

kill():Void

Calls kill() on the group's members and then on the group itself. You can revive this group later via revive() after this.

@:value({ Unique : false, Height : 0, Width : 0, Animated : false })loadGraphic(Graphic:FlxGraphicAsset, Animated:Bool = false, Width:Int = 0, Height:Int = 0, Unique:Bool = false, ?Key:String):FlxSprite

This functionality isn't supported in SpriteGroup

Returns:

this sprite group

loadGraphicFromSprite(Sprite:FlxSprite):FlxSprite

This functionality isn't supported in SpriteGroup

Returns:

this sprite group

@: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

This functionality isn't supported in SpriteGroup

Returns:

this sprite group

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

This functionality isn't supported in SpriteGroup

Returns:

this sprite group

@:genericmultiTransformChildren<V>(FunctionArray:Array<T‑>V‑>Void>, ValueArray:Array<V>):Void

Handy function that allows you to quickly transform multiple properties of sprites in this group at a time.

Parameters:

FunctionArray

Array of functions to transform sprites in this group.

ValueArray

Array of values which will be passed to lambda functions

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

Checks to see if a point in 2D world space overlaps any FlxSprite object from this group.

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 group.

@:value({ Mask : 0xFF })pixelsOverlapPoint(point:FlxPoint, Mask:Int = 0xFF, ?Camera:FlxCamera):Bool

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

Parameters:

Point

The point in world space you want to check.

Mask

Used in the pixel hit test to determine what counts as solid.

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.

@:value({ Force : false })inlinerecycle(?ObjectClass:Class<T>, ?ObjectFactory:Void‑>T, Force:Bool = false):T

Recycling is designed to help you reuse game objects without always re-allocating or "newing" them. It behaves differently depending on whether maxSize equals 0 or is bigger than 0.

maxSize > 0 / "rotating-recycling" (used by FlxEmitter): - at capacity: returns the next object in line, no matter its properties like alive, exists etc. - otherwise: returns a new object.

maxSize == 0 / "grow-style-recycling" - tries to find the first object with exists == false - otherwise: adds a new object to the members array

WARNING: If this function needs to create a new object, and no object class was provided, it will return null instead of a valid object!

Parameters:

ObjectClass

The class type you want to recycle (e.g. FlxSprite, EvilRobot, etc).

ObjectFactory

Optional factory function to create a new object if there aren't any dead members to recycle. If null, Type.createInstance() is used, which requires the class to have no constructor parameters.

Force

Force the object to be an ObjectClass and not a super class of ObjectClass.

Revive

Whether recycled members should automatically be revived (by calling revive() on them).

Returns:

A reference to the object that was created.

@:value({ Splice : false })remove(Sprite:T, Splice:Bool = false):T

Removes the specified sprite from the group.

Parameters:

Sprite

The FlxSprite you want to remove.

Splice

Whether the object should be cut from the array entirely or not.

Returns:

The removed sprite.

inlinereplace(OldObject:T, NewObject:T):T

Replaces an existing FlxSprite with a new one.

Parameters:

OldObject

The sprite you want to replace.

NewObject

The new object you want to use instead.

Returns:

The new sprite.

@:value({ FetchPositions : false })replaceColor(Color:Int, NewColor:Int, 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

revive():Void

Revives the group.

@:value({ Y : 0, X : 0 })setPosition(X:Float = 0, Y:Float = 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

@:value({ Order : FlxSort.ASCENDING })inlinesort(Function:Int‑>T‑>T‑>Int, Order:Int = FlxSort.ASCENDING):Void

Call this function to sort the group according to a particular value and order. For example, to sort game objects for Zelda-style overlaps you might call group.sort(FlxSort.byY, FlxSort.ASCENDING) at the bottom of your FlxState#update() override.

Parameters:

Function

The sorting function to use - you can use one of the premade ones in FlxSort or write your own using FlxSort.byValues() as a "backend".

Order

A constant that defines the sort order. Possible values are FlxSort.ASCENDING (default) and FlxSort.DESCENDING.

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

This functionality isn't supported in SpriteGroup

@:generictransformChildren<V>(Function:T‑>V‑>Void, Value:V):Void

Handy function that allows you to quickly transform one property of sprites in this group at a time.

Parameters:

Function

Function to transform the sprites. Example: function(sprite, v:Dynamic) { s.acceleration.x = v; s.makeGraphic(10,10,0xFF000000); }

Value

Value which will passed to lambda function.

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.

graphicLoaded():Void

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

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

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, blueOffset : 0, greenOffset : 0, redOffset : 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:Int = 0, greenOffset:Int = 0, blueOffset:Int = 0, alphaOffset:Int = 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:Int, FlipX:Bool, FlipY:Bool):Void

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

Parameters:

Direction

Use constants from FlxObject: 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(FlxObject.LEFT | FlxObject.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, Width : 0 })setGraphicSize(Width:Int = 0, Height:Int = 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 Integers 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.

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.

getScreenPosition(?point:FlxPoint, ?Camera:FlxCamera):FlxPoint

Call this function to figure out the on-screen position of the object.

Parameters:

Point

Takes a FlxPoint object and assigns the post-scrolled X and Y values of this object to it.

Camera

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

Returns:

The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object.

hurt(Damage:Float):Void

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:Int):Bool

Handy function for checking if this object is touching a particular surface. Be sure to check it before calling super.update(), as that will reset the flags.

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:Int):Bool

Handy function for checking if this object is just landed on a particular surface. Be sure to check it before calling super.update(), as that will reset the flags.

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.

screenCenter(?axes:FlxAxes):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 - default is FlxAxes.XY / both.

Returns:

This FlxObject for chaining

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.