Within addIcon(), it sets the key to a new string using it's own string. Because it combines the strings, the string continually grows in length when refreshing the sprite.
public function addIcon(icon:FlxSprite, X:Int = 0, Y:Int = 0, ?center:Bool = true)
...
// create a unique key for the new graphic
var key = graphic.key + ",icon:" + icon.graphic.key;
var newGraphic = FlxG.bitmap.add(newBmp, false, key);
...
This makes every addIcon call add a new image to the cache since the string is always different.
What's the best way to cache the graphic + icon without creating a new instance in the graphics cache? It needs to play nice with the removeIcon() code as well, which clears the graphic's bitmap.
If there's no easy way (or not necessary?), we could just set var newGraphic = FlxG.bitmap.add(newBmp); to avoid the growing string and allow the system to generate an incremental "pixels" + _lastUniqueKeyIndex key for the image.
Within
addIcon()
, it sets the key to a new string using it's own string. Because it combines the strings, the string continually grows in length when refreshing the sprite.This makes every
addIcon
call add a new image to the cache since the string is always different.What's the best way to cache the graphic + icon without creating a new instance in the graphics cache? It needs to play nice with the
removeIcon()
code as well, which clears the graphic's bitmap.If there's no easy way (or not necessary?), we could just set
var newGraphic = FlxG.bitmap.add(newBmp);
to avoid the growing string and allow the system to generate an incremental "pixels" +_lastUniqueKeyIndex
key for the image.