From 2da3523b254920452c52b5794d1a594cfb4ebad8 Mon Sep 17 00:00:00 2001 From: Gama11 Date: Tue, 20 Sep 2016 11:51:47 +0200 Subject: [PATCH] FlxSprite: fix default graphic not showing on HTML5 see openfl/openfl#682 --- flixel/FlxSprite.hx | 16 +++++++++------- include.xml | 5 ++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/flixel/FlxSprite.hx b/flixel/FlxSprite.hx index 24fced3484..00002c76d8 100644 --- a/flixel/FlxSprite.hx +++ b/flixel/FlxSprite.hx @@ -23,9 +23,6 @@ import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; using flixel.util.FlxColorTransformUtil; -@:keep @:bitmap("assets/images/logo/default.png") -private class GraphicDefault extends BitmapData {} - // TODO: add updateSizeFromFrame bool which will tell sprite whether to update it's size to frame's size (when frame setter is called) or not (useful for sprites with adjusted hitbox) // And don't forget about sprites with clipped frames: what i should do with their size in this case? @@ -621,13 +618,19 @@ class FlxSprite extends FlxObject animation.update(elapsed); } + @:noCompletion + private function checkEmptyFrame() + { + if (_frame == null) + loadGraphic("flixel/images/logo/default.png"); + } + /** * Called by game loop, updates then blits or renders current frame of animation to the screen */ override public function draw():Void { - if (_frame == null) - loadGraphic(FlxGraphic.fromClass(GraphicDefault)); + checkEmptyFrame(); if (alpha == 0 || _frame.type == FlxFrameType.EMPTY) return; @@ -891,8 +894,7 @@ class FlxSprite extends FlxObject @:noCompletion private function calcFrame(RunOnCpp:Bool = false):Void { - if (frame == null) - loadGraphic(FlxGraphic.fromClass(GraphicDefault)); + checkEmptyFrame(); if (FlxG.renderTile && !RunOnCpp) return; diff --git a/include.xml b/include.xml index a76024e386..4a6dce295c 100644 --- a/include.xml +++ b/include.xml @@ -10,7 +10,10 @@ - +
+ + +