Internal storage system to prevent graphics from being used repeatedly in memory.

Accessed via FlxG.bitmap.

Constructor

new()

Variables

read onlywhitePixel:FlxFrame

Helper FlxFrame object. Containing only one frame. Useful for drawing colored rectangles of all sizes in FlxG.renderTile mode.

Methods

@:value({ unique : false })add(graphic:FlxGraphicAsset, unique:Bool = false, ?key:String):FlxGraphic

Loads a bitmap from a file, clones it if necessary and caches it.

Parameters:

graphic

Optional FlxGraphics object to create FlxGraphic from.

unique

Ensures that the bitmap data uses a new slot in the cache.

key

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

Returns:

The FlxGraphic we just created.

inlineaddGraphic(graphic:FlxGraphic):FlxGraphic

Caches the specified graphic.

Parameters:

graphic

The graphic to cache.

Returns:

The cached graphic.

inlinecheckCache(key:String):Bool

Check the local bitmap cache to see if a bitmap with this key has been loaded already.

Parameters:

key

The key identifying the bitmap.

Returns:

Whether or not this file can be found in the cache.

@:has_untypedclearCache():Void

Clears image cache (and destroys those images). Graphics object will be removed and destroyed only if it shouldn't persist in the cache and its useCount is 0.

@:has_untypedclearUnused():Void

Removes all unused graphics from cache, but skips graphics which should persist in cache and shouldn't be destroyed on no use.

@:value({ unique : false })create(width:Int, height:Int, color:FlxColor, unique:Bool = false, ?key:String):FlxGraphic

Creates a new graphic of a colored rectangle and caches it.

Parameters:

width

How wide the rectangle should be.

height

How high the rectangle should be.

color

What color the rectangle should be (0xAARRGGBB).

unique

Ensures that the bitmap data uses a new slot in the cache.

key

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

Returns:

The created graphic.

@:has_untypedfindKeyForBitmap(bmd:BitmapData):String

Gets a key from a cached BitmapData.

Parameters:

bmd

BitmapData to find in the cache.

Returns:

The BitmapData's key or null if there isn't such BitmapData in cache.

@:value({ unique : false })generateKey(systemKey:String, userKey:String, unique:Bool = false):String

Creates string key for further caching.

Parameters:

systemKey

The first string key to use as a base for a new key. It's usually an asset key ("assets/image.png").

userKey

The second string key to use as a base for a new key. It's usually a key provided by the user

unique

Whether generated key should be unique or not.

Returns:

Created key.

inlineget(key:String):FlxGraphic

Gets an FlxGraphic object from this storage from its key.

Parameters:

key

The FlxGraphics key (or name).

Returns:

The FlxGraphic with the specified key, or null if the object doesn't exist.

inlinegetKeyForClass(source:Class<Dynamic>):String

Helper method for getting cache key for FlxGraphic objects created from the class.

Parameters:

source

BitmapData source class.

Returns:

Full name for provided class.

getKeyWithSpacesAndBorders(baseKey:String, ?frameSize:FlxPoint, ?frameSpacing:FlxPoint, ?frameBorder:FlxPoint, ?region:FlxRect):String

Generates key from provided base key and information about tile size and offsets in spritesheet and the region of image to use as spritesheet graphics source.

Parameters:

baseKey

Beginning of the key. Usually it is the key for original spritesheet graphics (like "assets/tile.png").

frameSize

The size of tile in spritesheet.

frameSpacing

Offsets between tiles in offsets.

region

Region of image to use as spritesheet graphics source.

Returns:

Generated key for spritesheet with inserted spaces between tiles.

getUniqueKey(?baseKey:String):String

Gets unique key for bitmap cache.

Parameters:

baseKey

key's prefix.

Returns:

unique key.

@:has_untypedonAssetsReload(_:Dynamic):Void

remove(graphic:FlxGraphic):Void

Totally removes specified FlxGraphic object.

Parameters:

graphic

The object you want to remove and destroy.

removeByKey(key:String):Void

Totally removes FlxGraphic object with specified key.

Parameters:

key

Key of the cached graphic.

@:has_untypedreset():Void

Completely resets bitmap cache, which means destroying ALL of the cached FlxGraphic objects.