HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.96k stars 432 forks source link

Double memory in FlxSprite #1593

Open MSGhero opened 9 years ago

MSGhero commented 9 years ago

Whenever FlxSprite functions (makeGraphic(), loadGraphic(), set_pixels()) are called for the first time, the input/created bitmapdata is always duplicated. One gets stored in frames[0], and another is created by framePixels = frame.paint(framePixels, ...) where parameter framePixels is null. This is fine if I have multiple frames, but for a static background image, I only need one copy of the image. This is a problem when I have 64 bg images that take up 36 MB alone, duplicating takes up 72 MB for no reason.

Is there any way to skip set_frames()/getFlxFrameBitmapData() while keeping FLX_RENDER_TILE enabled? Or would this require a new class?