Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class FlxG
*/
public static function addChildBelowMouse<T:DisplayObject>(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);
Expand Down Expand Up @@ -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
Expand Down
38 changes: 29 additions & 9 deletions flixel/FlxGame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it say use inputContainer instead of just use?That way users would know the new variable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol yep

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
/**
Expand Down Expand Up @@ -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)
{
Expand All @@ -248,15 +265,15 @@ class FlxGame extends Sprite
_startFullscreen = startFullscreen;
#end

// Super high priority init stuff
_inputContainer = new Sprite();
_inputContainer = inputContainer;

if (gameWidth == 0)
gameWidth = FlxG.stage.stageWidth;
if (gameHeight == 0)
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;
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -709,7 +729,7 @@ class FlxGame extends Sprite
}
#end

filters = filtersEnabled ? _filters : null;
filteredContainer.filters = filtersEnabled ? _filters : null;
}

function updateElapsed():Void
Expand Down
2 changes: 0 additions & 2 deletions flixel/system/debug/FlxDebugger.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment on lines -328 to -329
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also this needs to be reverted for my change in #3487 (comment), otherwise a portion of the debugger will be off screen

}

function updateBounds():Void
Expand Down
18 changes: 9 additions & 9 deletions flixel/system/frontEnds/CameraFrontEnd.hx
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<T:FlxCamera>(NewCamera:T, DefaultDrawTarget:Bool = true):T
public function add<T:FlxCamera>(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;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions flixel/system/scaleModes/BaseScaleMode.hx
Copy link
Contributor

@ACrazyTown ACrazyTown Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you meant by "figure out why resizing the window messes this up" but when testing this, I noticed that the sound tray and mouse were offset. Replacing this block with:

FlxG.game.x = offset.x;
FlxG.game.y = offset.y;

final rect = FlxG.game.filteredContainer.scrollRect;
rect.setTo(0, 0, gameSize.x, gameSize.y);
FlxG.game.filteredContainer.scrollRect = rect;

seemed to fix things for me.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 1 addition & 7 deletions flixel/system/scaleModes/FillScaleMode.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}