Search code examples
bitmaphaxehaxeflixel

HaxeFlixel, loadGraphic() for a Bitmap


I have problems triying to set a Bitmap in the method loadGraphic() of the SpriteSheet.

var bd:BitmapData = Assets.getBitmapData("images/MenuDoorTopV1.0_640x260.png");
var b:Bitmap = new Bitmap(bd);

_CompuertaTop = new FlxSprite(-1000, -1000);
_CompuertaTop.loadGraphic(b, false, 0, 0);

Solution

  • You need to pass the actual BitmapData instance to loadGraphic().

    Also, there's no need to use Assets.getBitmapData() in this case, loadGraphic() does that call for you if you pass the String path:

    _CompuertaTop.loadGraphic("images/MenuDoorTopV1.0_640x260.png", false, 0, 0);