Skip to content

FlxUIButton creates incrementally larger graphic keys #268

@DigiEggz

Description

@DigiEggz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions