Use scrollRect to clip filters and position game window - #3487
Conversation
|
@ACrazyTown originally I wasn't going to add the new containers, but this didn't work without it, specifically with |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
Fixes #2258
Adds a scrollRect to the game to ensure that game filters are the expected size. Also adds public
filteredContainer,inputContainerandcameraContainerfields toFlxGamewhile deprecating the old private_inputContainerfield. This is both to show the debugger above the game filters and organize things better so that the dev can simply add filters toFlxG.game.cameraContainerdirectly.I tested this with the ScaleModes demo and it seems to work for every mode.
TODO: figure out why resizing the window messes this up even though the rect values are as expected