Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlxUIButton creates incrementally larger graphic keys #268

Open
DigiEggz opened this issue Feb 2, 2024 · 0 comments
Open

FlxUIButton creates incrementally larger graphic keys #268

DigiEggz opened this issue Feb 2, 2024 · 0 comments

Comments

@DigiEggz
Copy link
Contributor

DigiEggz commented Feb 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant