HaxeFlixel / HaxeFlixel/flixel-ui
FlxUIButton creates incrementally larger graphic keys
Nobody has claimed this yet.
- Dominant language
- Haxe
- Stars
- 201
- Forks
- 75
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in FlxUIButton.addIcon(), focusing on how the graphic key is composed and passed to FlxG.bitmap.add(). Read removeIcon() alongside it to understand bitmap clearing and cache ownership. Done means repeated sprite refreshes do not create ever-growing cache keys and remain compatible with removeIcon().
Written by the indexing model from the issue text.
Assessment
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100