diff --git a/flixel/FlxSubState.hx b/flixel/FlxSubState.hx index c657ad7cd5..7e614d48fe 100644 --- a/flixel/FlxSubState.hx +++ b/flixel/FlxSubState.hx @@ -45,17 +45,19 @@ class FlxSubState extends FlxState var _created:Bool = false; /** - * @param BGColor background color for this substate + * @param bgColor background color for this substate */ - public function new(BGColor:FlxColor = FlxColor.TRANSPARENT) + public function new(bgColor = FlxColor.TRANSPARENT) { super(); closeCallback = null; openCallback = null; if (FlxG.renderTile) + { _bgSprite = new FlxBGSprite(); - bgColor = BGColor; + } + this.bgColor = bgColor; } override public function draw():Void @@ -68,9 +70,10 @@ class FlxSubState extends FlxState camera.fill(bgColor); } } - else + else // FlxG.renderTile { - _bgSprite.draw(); + if (_bgSprite != null && _bgSprite.visible) + _bgSprite.draw(); } // Now draw all children @@ -102,11 +105,15 @@ class FlxSubState extends FlxState } @:noCompletion - override function set_bgColor(Value:FlxColor):FlxColor + override function set_bgColor(value:FlxColor):FlxColor { if (FlxG.renderTile && _bgSprite != null) - _bgSprite.pixels.setPixel32(0, 0, Value); + { + _bgSprite.alpha = value.alphaFloat; + _bgSprite.visible = _bgSprite.alpha > 0; + _bgSprite.color = value.rgb; + } - return _bgColor = Value; + return _bgColor = value; } } diff --git a/flixel/system/FlxBGSprite.hx b/flixel/system/FlxBGSprite.hx index 85407277ae..125c321381 100644 --- a/flixel/system/FlxBGSprite.hx +++ b/flixel/system/FlxBGSprite.hx @@ -10,6 +10,7 @@ class FlxBGSprite extends FlxSprite public function new() { super(); + // TODO: Use unique:false, now that we're not editing the pixels makeGraphic(1, 1, FlxColor.WHITE, true, FlxG.bitmap.getUniqueKey("bg_graphic_")); scrollFactor.set(); } @@ -29,6 +30,7 @@ class FlxBGSprite extends FlxSprite _matrix.identity(); _matrix.scale(camera.viewWidth, camera.viewHeight); + _matrix.translate(camera.viewMarginLeft, camera.viewMarginTop); camera.drawPixels(frame, _matrix, colorTransform); #if FLX_DEBUG