BitmapData wrapper which is used for rendering. It stores info about all frames, generated for specific BitmapData object.

Static variables

@:value(false)staticdefaultPersist:Bool = false

The default value for the persist variable at creation if none is specified in the constructor.

See also:

Static methods

@:value({ Cache : true, Unique : false })staticfromAssetKey(Source:String, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic

Creates and caches FlxGraphic object from openfl.Assets key string.

Parameters:

Source

openfl.Assets key string. For example: "assets/image.png".

Unique

Ensures that the BitmapData uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Cache

Whether to use graphic caching or not. Default value is true, which means automatic caching.

Returns:

Cached FlxGraphic object we just created.

@:value({ Cache : true, Unique : false })staticfromBitmapData(Source:BitmapData, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic

Creates and caches FlxGraphic object from specified BitmapData object.

Parameters:

Source

BitmapData for FlxGraphic to use.

Unique

Ensures that the BitmapData uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Cache

Whether to use graphic caching or not. Default value is true, which means automatic caching.

Returns:

FlxGraphic object we just created.

@:value({ Cache : true, Unique : false })staticfromClass(Source:Class<BitmapData>, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic

Creates and caches FlxGraphic object from a specified Class<BitmapData>.

Parameters:

Source

Class<BitmapData> to create BitmapData for FlxGraphic from.

Unique

Ensures that the BitmapData uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Cache

Whether to use graphic caching or not. Default value is true, which means automatic caching.

Returns:

FlxGraphic object we just created.

@:value({ Cache : true, Unique : false })staticfromFrame(Source:FlxFrame, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic

Creates and (optionally) caches a FlxGraphic object from the specified FlxFrame. It uses frame's BitmapData, not the frame.parent.bitmap.

Parameters:

Source

FlxFrame to get the BitmapData from.

Unique

Ensures that the bitmap data uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Cache

Whether to use graphic caching or not. Default value is true, which means automatic caching.

Returns:

FlxGraphic object we just created.

@:value({ Unique : false })staticinlinefromFrames(Source:FlxFramesCollection, Unique:Bool = false, ?Key:String):FlxGraphic

Creates and caches a FlxGraphic object from the specified FlxFramesCollection. It uses frames.parent.bitmap as a source for the FlxGraphic's BitmapData. It also copies all the frames collections onto the newly created FlxGraphic.

Parameters:

Source

FlxFramesCollection to get the BitmapData from.

Unique

Ensures that the BitmapData uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Returns:

Cached FlxGraphic object we just created.

@:value({ Unique : false })staticfromGraphic(Source:FlxGraphic, Unique:Bool = false, ?Key:String):FlxGraphic

Creates and caches a FlxGraphic object from the specified FlxGraphic object. It copies all the frame collections onto the newly created FlxGraphic.

Parameters:

Source

FlxGraphic to get the BitmapData from.

Unique

Ensures that the BitmapData uses a new slot in the cache. If true, then BitmapData for this FlxGraphic will be cloned, which means extra memory.

Key

Force the cache to use a specific key to index the bitmap.

Returns:

Cached FlxGraphic object we just created.

@:value({ Unique : false })staticfromRectangle(Width:Int, Height:Int, Color:FlxColor, Unique:Bool = false, ?Key:String):FlxGraphic

Generates and caches new FlxGraphic object with a colored rectangle.

Parameters:

Width

How wide the rectangle should be.

Height

How high the rectangle should be.

Color

What color the rectangle should have (0xAARRGGBB).

Unique

Ensures that the BitmapData uses a new slot in the cache.

Key

Force the cache to use a specific key to index the bitmap.

Returns:

The FlxGraphic object we just created.

Variables

read onlyassetsClass:Class<BitmapData>

Class name for the BitmapData.

read onlyassetsKey:String

Asset name from openfl.Assets.

read onlyatlasFrames:FlxAtlasFrames

Atlas frames for this graphic. You should fill it yourself with one of FlxAtlasFrames's static methods (like fromTexturePackerJson(), fromTexturePackerXml(), etc).

bitmap:BitmapData

The cached BitmapData object.

read onlycanBeDumped:Bool

Whether the BitmapData of this graphic object can be dumped for decreased memory usage, but may cause some issues (when you need direct access to pixels of this graphic. If the graphic is dumped then you should call undump() and have total access to pixels.

@:value(true)destroyOnNoUse:Bool = true

Whether this FlxGraphic should be destroyed when useCount becomes zero (defaults to true). Has no effect when persist is true.

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

Height of the cached BitmapData.

read onlyimageFrame:FlxImageFrame

FlxImageFrame object for the whole bitmap.

read onlyisDestroyed:Bool

Whether destroy was called on this graphic

Available since

5.6.0

.

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

Whether the BitmapData of this graphic object has been dumped or not.

read onlyisLoaded:Bool

Whether the BitmapData of this graphic object has been loaded or not.

read onlykey:String

Key used in the BitmapFrontEnd cache.

@:value(false)persist:Bool = false

Whether this graphic object should stay in the cache after state changes or not. destroyOnNoUse has no effect when this is set to true.

read onlyshader:FlxShader

GLSL shader for this graphic. Only used if utilizing sprites do not define a shader Avoid changing it frequently as this is a costly operation.

@:value(false)unique:Bool = false

Shows whether this object unique in cache or not.

Whether undumped BitmapData should be cloned or not. It is false by default, since it significantly increases memory consumption.

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

Usage counter for this FlxGraphic object.

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

Width of the cached BitmapData.

Methods

addFrameCollection(collection:FlxFramesCollection):Void

Stores specified FlxFrame collection in internal map (this helps reduce object creation).

Parameters:

collection

frame collection to store.

destroy():Void

Trying to free the memory as much as possible

dump():Void

Dumps bits of BitmapData to decrease memory usage, but you can't read/write pixels on it anymore (but you can call onContext() (or undump()) method which will restore it again).

inlinegetEmptyFrame(size:FlxPoint):FlxFrame

Creates empty frame for this graphic with specified size. This method could be useful for tile frames, in case when you'll need empty tile.

Parameters:

size

dimensions of the frame to add.

Returns:

Empty frame with specified size which belongs to this FlxGraphic object.

inlinegetFramesCollections(type:FlxFrameCollectionType):Array<Dynamic>

Searches frame collections of specified type for this FlxGraphic object.

Parameters:

type

The type of frames collections to search for.

Returns:

Array of available frames collections of specified type for this object.

onAssetsReload():Void

Asset reload callback for this graphic object. It regenerated its tilesheet and resets frame bitmaps.

onContext():Void

Use this method to restore cached BitmapData (if it's possible). It's called automatically when the RESIZE event occurs.

undump():Void

Undumps bits of the BitmapData - regenerates it and regenerate tilesheet data for this object