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 @@ -489,7 +489,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 @@ -557,7 +557,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 inputContainer")
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
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
4 changes: 4 additions & 0 deletions flixel/system/scaleModes/BaseScaleMode.hx

@ACrazyTown ACrazyTown Sep 22, 2025

Copy link
Copy Markdown
Contributor

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.

@Geokureli Geokureli Jul 13, 2026

Copy link
Copy Markdown
Member Author

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.

If the window is manually resized via dragging, the error observed in #2258 happens. It's very apparent in Ratio (screenFill) Mode of the scalemodes demo. I'm using Filipp8's border shader to keep track of the screen size. This also happens in release mode so I don't think it's the debugger.

This happens even with your changes

Full example here: https://gist.github.com/Geokureli/eac8544261befb05cb36182676f8fb60

Edit: I noticed in my issue, above, if you disable filters and then re-enable filters - via FlxG.game.filtersEnabled - the issue is corrected. I also notice the issue happens when switching to different modes, it's also corrected when toggling filters on and off.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Edit: I noticed in my issue, above, if you disable filters and then re-enable filters - via FlxG.game.filtersEnabled - the issue is corrected. I also notice the issue happens when switching to different modes, it's also corrected when toggling filters on and off.

That sounds oddly similar to #2258 (comment). I wonder if my camera shader fix in OpenFL (openfl/openfl#2797) would also fix this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll try it out

Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ class BaseScaleMode

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;
}

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 {}
Loading