Problem with rendering to proper sprite coordinates
- Haxe version: 4.3.6
- Flixel version: 5.9.0
- OpenFL version: 9.4.1
- Lime version: 8.2.2
- Affected targets: HL and Native (macOS arm and linux, couldn't test windows)
Code snippet reproducing the issue:
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.util.FlxColor;
class PlayState extends FlxState
{
override public function create()
{
super.create();
bgColor = 0xFFE40066;
var sprite = new FlxSprite();
sprite.makeGraphic(200, 200, 0xFF345995);
sprite.x = FlxG.width - sprite.width;
sprite.y = 200;
add(sprite);
}
override public function update(elapsed:Float)
{
super.update(elapsed);
}
}
Minimum project if you want to clone and run quickly: https://github.com/kfjustis/SpriteOffsetBug
Observed behavior: The right side of the sprite rect is not exactly flush with the edge of the play area after maximizing the game window. By maximize, I mean both resizing the window and true fullscreen.
After launching the game via lime test hl:
After maximizing the window via double-clicking the title bar:
Cropped and zoomed in to show the extremely tiny offset issue (some pink comes through between the blue sprite and the black bar on the right):
Expected behavior: There should be no gap between the right side of the sprite and the black bar.
Totally possible that this if from a lower-level library like OpenFL, but I found this during my prototyping for a Haxe Winter Jam project and haven't seen anyone else mention a similar issue. My HashLink version is a little outdated since I could only get the version that comes with lime to work on my Mac, but it happens on my Linux desktop and through the native target as well. Any info would be great!
Confirmed this is an OpenFL issue. I reverted to 9.4.0 from 9.4.1 and the gap is gone. Will try to make an issue in OpenFL repo instead.
Okay, now I am unsure. I tried to make a representative example with pure OpenFL and, even on 9.4.1, there is no visible gap. Could this mean there is a bug between OpenFL 9.4.0 and 9.4.1 wherever HaxeFlixel manages the abstraction?
Don't have enough knowledge with these frameworks to guess, but if someone could double-check me, that'd be great. Here is the link to the OpenFL minimum example: https://github.com/kfjustis/SpriteOffsetBugOpenFL
Versions when running OpenFL:
- lime 8.2.2
- openfl 9.4.1
- haxe 4.3.6
Maybe the way I handled the scaling manually is not representative of what Flixel does.
I appreciate you doing all this work, I'll do a deep dive over the weekend and pass the buck to openfl is this is, in fact, a problem on their end. I'll be able to try Mac and Windows, too
Have you checked camera.pixelPerfectRender and object.pixelPerfectRender? I believe it affects object positioning
@DetectiveBaldi Those settings did not seem to make a difference for me. I also tried them after setting FlxG.scaleMode = new PixelPerfectScaleMode(), and while the mode correctly changed the window scaling, the gap between the sprite and the stage still appears.