diff --git a/flixel/FlxG.hx b/flixel/FlxG.hx index baad5bdbb7..39095b983d 100644 --- a/flixel/FlxG.hx +++ b/flixel/FlxG.hx @@ -487,7 +487,7 @@ class FlxG */ public static function addChildBelowMouse(child:T, indexModifier = 0):T { - var index = game.getChildIndex(game._inputContainer); + var index = game.getChildIndex(game.inputContainer); var max = game.numChildren; index = FlxMath.maxAdd(index, indexModifier, max); @@ -551,7 +551,7 @@ class FlxG #end #if FLX_MOUSE - mouse = inputs.addInput(new FlxMouse(game._inputContainer)); + mouse = inputs.addInput(new FlxMouse(game.inputContainer)); #end #if FLX_TOUCH diff --git a/flixel/FlxGame.hx b/flixel/FlxGame.hx index 6f9eb08b3b..b65533ad89 100644 --- a/flixel/FlxGame.hx +++ b/flixel/FlxGame.hx @@ -12,6 +12,7 @@ import openfl.display.StageAlign; import openfl.display.StageScaleMode; import openfl.events.Event; import openfl.filters.BitmapFilter; +import openfl.geom.Rectangle; #if desktop import openfl.events.FocusEvent; #end @@ -155,9 +156,24 @@ class FlxGame extends Sprite /** * Mouse cursor. */ - @:allow(flixel.FlxG) - @:allow(flixel.system.frontEnds.CameraFrontEnd) - var _inputContainer:Sprite; + @:deprecated("_inputContainer is deprecated, use") + final _inputContainer:Sprite; + + /** + * Container for the `FlxMouse` cursor, reads mouse input + */ + public final inputContainer = new Sprite(); + + /** + * Container for all sprites that will be affected by game filters. By default, includes + * `cameraContainer`, the mouse and the sound tray + */ + public final filteredContainer = new Sprite(); + + /** + * The container that all cameras are added to, when passed into `FlxG.cameras.add` + */ + public final cameraContainer = new Sprite(); #if FLX_SOUND_TRAY /** @@ -239,6 +255,7 @@ class FlxGame extends Sprite * * @see [scale modes](https://api.haxeflixel.com/flixel/system/scaleModes/index.html) */ + @:haxe.warning("-WDeprecated") public function new(gameWidth = 0, gameHeight = 0, ?initialState:InitialState, updateFramerate = 60, drawFramerate = 60, skipSplash = false, startFullscreen = false) { @@ -248,8 +265,7 @@ class FlxGame extends Sprite _startFullscreen = startFullscreen; #end - // Super high priority init stuff - _inputContainer = new Sprite(); + _inputContainer = inputContainer; if (gameWidth == 0) gameWidth = FlxG.stage.stageWidth; @@ -257,6 +273,7 @@ class FlxGame extends Sprite gameHeight = FlxG.stage.stageHeight; // Basic display and update setup stuff + filteredContainer.scrollRect = new Rectangle(0, 0, FlxG.stage.stageWidth, FlxG.stage.stageHeight); FlxG.init(this, gameWidth, gameHeight); FlxG.updateFramerate = updateFramerate; @@ -304,7 +321,8 @@ class FlxGame extends Sprite stage.align = StageAlign.TOP_LEFT; stage.frameRate = FlxG.drawFramerate; - addChild(_inputContainer); + addChild(filteredContainer); + filteredContainer.addChild(cameraContainer); // Creating the debugger overlay #if FLX_DEBUG @@ -317,12 +335,14 @@ class FlxGame extends Sprite // Volume display tab #if FLX_SOUND_TRAY soundTray = Type.createInstance(_customSoundTray, []); - addChild(soundTray); + filteredContainer.addChild(soundTray); #end + + filteredContainer.addChild(inputContainer); #if FLX_FOCUS_LOST_SCREEN _focusLostScreen = Type.createInstance(_customFocusLostScreen, []); - addChild(_focusLostScreen); + filteredContainer.addChild(_focusLostScreen); #end #end @@ -709,7 +729,7 @@ class FlxGame extends Sprite } #end - filters = filtersEnabled ? _filters : null; + filteredContainer.filters = filtersEnabled ? _filters : null; } function updateElapsed():Void diff --git a/flixel/system/debug/FlxDebugger.hx b/flixel/system/debug/FlxDebugger.hx index afc67bb790..c4cbf8d9ab 100644 --- a/flixel/system/debug/FlxDebugger.hx +++ b/flixel/system/debug/FlxDebugger.hx @@ -325,8 +325,6 @@ class FlxDebugger extends openfl.display.Sprite resetButtonLayout(); resetLayout(); scaleX = scaleY = scale; - x = -FlxG.scaleMode.offset.x; - y = -FlxG.scaleMode.offset.y; } function updateBounds():Void diff --git a/flixel/system/frontEnds/CameraFrontEnd.hx b/flixel/system/frontEnds/CameraFrontEnd.hx index 965d0eff3d..fec47af59b 100644 --- a/flixel/system/frontEnds/CameraFrontEnd.hx +++ b/flixel/system/frontEnds/CameraFrontEnd.hx @@ -1,11 +1,11 @@ package flixel.system.frontEnds; -import openfl.geom.Rectangle; import flixel.FlxCamera; import flixel.FlxG; import flixel.util.FlxAxes; import flixel.util.FlxColor; import flixel.util.FlxSignal.FlxTypedSignal; +import openfl.geom.Rectangle; using flixel.util.FlxArrayUtil; @@ -62,17 +62,17 @@ class CameraFrontEnd * `FlxBasics` will not render to it unless you add it to their `cameras` list. * @return This FlxCamera instance. */ - public function add(NewCamera:T, DefaultDrawTarget:Bool = true):T + public function add(cam:T, defaultDrawTarget = true):T { - FlxG.game.addChildAt(NewCamera.flashSprite, FlxG.game.getChildIndex(FlxG.game._inputContainer)); + FlxG.game.cameraContainer.addChild(cam.flashSprite); - list.push(NewCamera); - if (DefaultDrawTarget) - defaults.push(NewCamera); + list.push(cam); + if (defaultDrawTarget) + defaults.push(cam); - NewCamera.ID = list.length - 1; - cameraAdded.dispatch(NewCamera); - return NewCamera; + cam.ID = list.length - 1; + cameraAdded.dispatch(cam); + return cam; } /** diff --git a/flixel/system/scaleModes/BaseScaleMode.hx b/flixel/system/scaleModes/BaseScaleMode.hx index 48d6cd11e2..0003967740 100644 --- a/flixel/system/scaleModes/BaseScaleMode.hx +++ b/flixel/system/scaleModes/BaseScaleMode.hx @@ -89,8 +89,9 @@ class BaseScaleMode if (FlxG.game == null) return; - FlxG.game.x = offset.x; - FlxG.game.y = offset.y; + final rect = FlxG.game.filteredContainer.scrollRect; + rect.setTo(-offset.x, -offset.y, deviceSize.x, deviceSize.y); + FlxG.game.filteredContainer.scrollRect = rect; } function set_horizontalAlign(value:FlxHorizontalAlign):FlxHorizontalAlign diff --git a/flixel/system/scaleModes/FillScaleMode.hx b/flixel/system/scaleModes/FillScaleMode.hx index ea98e24426..04d85a32af 100644 --- a/flixel/system/scaleModes/FillScaleMode.hx +++ b/flixel/system/scaleModes/FillScaleMode.hx @@ -8,10 +8,4 @@ import flixel.FlxG; * * To enable it in your project, use `FlxG.scaleMode = new FillScaleMode();`. */ -class FillScaleMode extends BaseScaleMode -{ - override function updateGamePosition():Void - { - FlxG.game.x = FlxG.game.y = 0; - } -} +class FillScaleMode extends BaseScaleMode {}