Single-frame collection. Could be useful for non-animated sprites.

Static methods

staticfindEmptyFrame(graphic:FlxGraphic, frameRect:FlxRect):FlxImageFrame

Searches FlxImageFrame object with the empty frame which have specified size.

Parameters:

graphic

FlxGraphic object to search FlxImageFrame for.

frameRect

The size of empty frame to search for.

Returns:

FlxImageFrame with empty frame.

staticfindFrame(graphic:FlxGraphic, frameRect:FlxRect, ?frameBorder:FlxPoint):FlxImageFrame

Searches FlxImageFrame object for specified FlxGraphic object which have the same frame rectangle.

Parameters:

graphic

FlxGraphic object to search the FlxImageFrame for.

frameRect

FlxImageFrame object should have frame with the same position and dimensions as specified with this argument.

Returns:

FlxImageFrame object which corresponds to specified rectangle. Could be null if there is no such FlxImageFrame.

staticfromBitmapAddSpacesAndBorders(source:FlxGraphicAsset, border:FlxPoint, ?region:FlxRect):FlxImageFrame

Gets source BitmapData, generates new BitmapData (if there is no such BitmapData in the cache already) and creates FlxImageFrame collection.

Parameters:

source

The source of graphic for frame collection.

border

Border to add around tiles (helps to avoid "tearing" problem).

region

Region of image to generate image frame from. Default value is null, which means that whole image will be used for it.

Returns:

Newly created image frame collection.

staticfromEmptyFrame(graphic:FlxGraphic, frameRect:FlxRect):FlxImageFrame

Generates a FlxImageFrame object with empty frame of specified size.

Parameters:

graphic

Graphic for the FlxImageFrame.

frameRect

The size of the empty frame to generate (only width and height of the frameRect need to be set properly).

Returns:

Newly created FlxImageFrame object with empty frame of specified size.

staticfromFrame(source:FlxFrame):FlxImageFrame

Generates a FlxImageFrame object from the specified FlxFrame.

Parameters:

source

FlxFrame to generate FlxImageFrame from.

Returns:

Created FlxImageFrame object.

staticfromFrameAddSpacesAndBorders(frame:FlxFrame, border:FlxPoint):FlxImageFrame

Gets FlxFrame object, generates new BitmapData with border pixels around (if there is no such BitmapData in the cache already) and creates image frame collection.

Parameters:

frame

Frame to generate tiles from.

border

Border to add around frame image (helps to avoid "tearing" problem).

Returns:

Newly created image frame collection.

staticfromGraphic(graphic:FlxGraphic, ?region:FlxRect):FlxImageFrame

Creates FlxImageFrame for the specified region of FlxGraphic.

Parameters:

graphic

Graphic for FlxImageFrame.

region

Region of image to create the FlxImageFrame for.

Returns:

Newly created FlxImageFrame object for the specified region of FlxGraphic object.

staticfromImage(source:FlxGraphicAsset):FlxImageFrame

Creates a FlxImageFrame object for the whole image.

Parameters:

source

image graphic for the FlxImageFrame.

Returns:

Newly created FlxImageFrame object for specified graphic.

staticfromRectangle(source:FlxGraphicAsset, ?region:FlxRect):FlxImageFrame

Creates a FlxImageFrame object for specified region of the image.

Parameters:

source

Image graphic for FlxImageFrame.

region

Region of the image to create the FlxImageFrame for.

Returns:

Newly created FlxImageFrame object for specified region of image.

Variables

read onlyframe:FlxFrame

Single frame of this frame collection. Added this var for faster access, so you don't need to type something like: imageFrame.frames[0]

Methods

Inherited Variables

Defined by FlxFramesCollection

read onlyborder:FlxPoint

How much space was trimmed around the original frames. Use addBorder() to add borders.

frames:Array<FlxFrame>

Array with all frames of this collection.

framesHash:Map<String, FlxFrame>

Deprecated: "`framesHash` is deprecated, use `getByName()` or `exists()`"

Hash of frames for this frame collection. Used only in FlxAtlasFrames and FlxBitmapFont (not implemented yet), but you can try to use it for other types of collections (give names to your frames).

read onlynumFrames:Int

Number of frames in this collection.

parent:FlxGraphic

Graphic object this frames belongs to.

read onlytype:FlxFrameCollectionType

Type of this frame collection. Used for faster type detection (less casting).

Inherited Methods

Defined by FlxFramesCollection

@:value({ duration : 0.0, flipY : false, flipX : false, angle : 0 })addAtlasFrame(frame:FlxRect, sourceSize:FlxPoint, offset:FlxPoint, ?name:String, angle:FlxFrameAngle = 0, flipX:Bool = false, flipY:Bool = false, duration:Float = 0.0):FlxFrame

Adds new frame to this frame collection. This method runs additional check, and can add rotated frames (from texture atlases).

Parameters:

frame

Region of image.

sourceSize

Original size of packed image (if image had been cropped, then original size will be bigger than frame size).

offset

How frame region is located on original frame image (offset from top left corner of original image).

name

Name for this frame (name of packed image file).

angle

Rotation of packed image (can be 0, 90 or -90).

flipX

If packed image should be horizontally flipped.

flipY

If packed image should be vertically flipped.

duration

The duration of this frame in seconds. If 0, the anim controller will decide the duration.

Returns:

Newly created and added frame object.

addEmptyFrame(size:FlxRect):FlxFrame

Adds empty frame into this frame collection. An empty frame is doing almost nothing for all the time.

Parameters:

size

Dimensions of the frame to add.

Returns:

Newly added empty frame.

addFrameOffset(name:String, offsetX:Float, offsetY:Float):Void

Adjusts the target frame's offset by the specified values. This mainly exists because certain atlas exporters don't give the correct offset. If no frame with the specified name exists, a warning is logged.

Parameters:

name

The name of the frame.

offsetX

The horizontal adjustment added to the frame's current offset.

offsetY

The vertical adjustment added to the frame's current offset.

Available since

5.3.0

.

@:value({ warnIfEmpty : true })addFramesOffsetByPrefix(prefix:String, offsetX:Float, offsetY:Float, warnIfEmpty:Bool = true):Void

Adjusts all frames with the specified name prefix by the specified offset. This mainly exists because certain atlas exporters don't give the correct offset.

Parameters:

prefix

The prefix used to determine which frames are affected.

offsetX

The horizontal adjustment added to the frame's current offset.

offsetY

The vertical adjustment added to the frame's current offset.

warnIfEmpty

Whether to log a warning if no frames with the prefix are found.

Available since

5.3.0

.

addSpriteSheetFrame(region:FlxRect):FlxFrame

Adds new regular (not rotated) FlxFrame to this frame collection.

Parameters:

region

Region of image which new frame will display.

Returns:

Newly created FlxFrame object for specified region of image.

inlineexists(name:String):Bool

Whether the collection has frame with the specified name.

Parameters:

name

The name of the frame to find.

Returns:

Whether the collection has frame with the specified name.

@:value({ warnIfEmpty : true })inlineforEachByPrefix(prefix:String, func:FlxFrame ‑> Void, warnIfEmpty:Bool = true, ?warningMsg:String):Void

Calls the given function on each frame whose name matches the specified prefix.

Note: This method is inlined so that optimizations are made when a literal anonymous functions or inlined functions are passed in, or when literal false is used for warnIfEmpty. Meaning, this is often more performant than getAllByPrefix.

Parameters:

prefix

The name prefix to look for.

Available since

5.3.0

.

getAllByPrefix(prefix:String):Array<FlxFrame>

Retrieves all frames with names starting with the specified prefix in an Array.

Parameters:

prefix

The name prefix to look for.

Available since

5.3.0

.

inlinegetByIndex(index:Int):FlxFrame

Finds frame in frames array by its index.

Parameters:

index

Index of the frame in the frames array.

Returns:

Frame with specified index in this frames collection (if there is one).

inlinegetByName(name:String):FlxFrame

Finds a frame in the collection by its name.

Parameters:

name

The name of the frame to find.

Returns:

Frame with specified name (if there is one).

inlinegetFrameIndex(frame:FlxFrame):Int

Finds the index of the specified frame in the frames array.

Parameters:

frame

Frame to find.

Returns:

Index of the specified frame.

getIndexByName(name:String):Int

Finds frame index by its name.

Parameters:

name

Name of the frame.

Returns:

Index of the frame with specified name.

@:value({ overwriteHash : false })pushFrame(frameObj:FlxFrame, overwriteHash:Bool = false):FlxFrame

Helper method for a adding frame to the collection.

Parameters:

frameObj

Frame to add.

overwriteHash

If true, any new frames with matching names will replace old ones.

Returns:

Added frame.

setFrameDuration(name:String, duration:Float):Void

Sets the target frame's offset to the specified values. This mainly exists because certain atlas exporters don't give the correct offset. If no frame with the specified name exists, a warning is logged.

Parameters:

name

The name of the frame.

duration

The new duration of the frame.

Available since

5.3.0

.

setFrameOffset(name:String, offsetX:Float, offsetY:Float):Void

Sets the target frame's offset to the specified values. This mainly exists because certain atlas exporters don't give the correct offset. If no frame with the specified name exists, a warning is logged.

Parameters:

name

The name of the frame.

offsetX

The new horizontal offset of the frame.

offsetY

The new vertical offset of the frame.

Available since

5.3.0

.

@:value({ warnIfEmpty : true })setFramesOffsetByPrefix(prefix:String, offsetX:Float, offsetY:Float, warnIfEmpty:Bool = true):Void

Sets all frames with the specified name prefix to the specified offset. This mainly exists because certain atlas exporters don't give the correct offset.

Parameters:

prefix

The prefix used to determine which frames are affected.

offsetX

The new horizontal offset of the frame.

offsetY

The new vertical offset of the frame.

warnIfEmpty

Whether to log a warning if no frames with the prefix are found.

Available since

5.3.0

.