BitmapData wrapper which is used for rendering.
It stores info about all frames, generated for specific BitmapData object.
Static variables
staticdefaultPersist:Bool = false
The default value for the persist variable
at creation if none is specified in the constructor.
Static methods
staticfromAssetKey(Source:String, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic
Creates and caches FlxGraphic object from openfl.Assets key string.
Parameters:
Source |
|
|---|---|
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Cache | Whether to use graphic caching or not. Default value is |
Returns:
Cached FlxGraphic object we just created.
staticfromBitmapData(Source:BitmapData, Unique:Bool = false, ?Key:String, Cache:Bool = true):FlxGraphic
Creates and caches FlxGraphic object from specified BitmapData object.
Parameters:
Source |
|
|---|---|
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Cache | Whether to use graphic caching or not. Default value is |
Returns:
FlxGraphic object we just created.
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 |
|
|---|---|
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Cache | Whether to use graphic caching or not. Default value is |
Returns:
FlxGraphic object we just created.
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 |
|
|---|---|
Unique | Ensures that the bitmap data uses a new slot in the cache.
If |
Key | Force the cache to use a specific key to index the bitmap. |
Cache | Whether to use graphic caching or not. Default value is |
Returns:
FlxGraphic object we just created.
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 |
|
|---|---|
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Returns:
Cached FlxGraphic object we just created.
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 |
|
|---|---|
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Returns:
Cached FlxGraphic object we just created.
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 ( |
Unique | Ensures that the |
Key | Force the cache to use a specific key to index the bitmap. |
Returns:
The FlxGraphic object we just created.
Variables
read onlyatlasFrames:FlxAtlasFrames
Atlas frames for this graphic.
You should fill it yourself with one of FlxAtlasFrames's static methods
(like fromTexturePackerJson(), fromTexturePackerXml(), etc).
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.
destroyOnNoUse:Bool
Whether this FlxGraphic should be destroyed when useCount becomes zero (defaults to true).
Has no effect when persist is true.
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.
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.
Methods
addFrameCollection(collection:FlxFramesCollection):Void
Stores specified FlxFrame collection in internal map (this helps reduce object creation).
Parameters:
collection | frame collection to store. |
|---|
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