Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with rendering to proper sprite coordinates #3334

Open
kfjustis opened this issue Jan 8, 2025 · 6 comments
Open

Problem with rendering to proper sprite coordinates #3334

kfjustis opened this issue Jan 8, 2025 · 6 comments

Comments

@kfjustis
Copy link

kfjustis commented Jan 8, 2025

  • 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:
image

After maximizing the window via double-clicking the title bar:
image

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):
image

Expected behavior: There should be no gap between the right side of the sprite and the black bar.

@kfjustis
Copy link
Author

kfjustis commented Jan 8, 2025

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!

@kfjustis
Copy link
Author

kfjustis commented Jan 9, 2025

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.

@kfjustis kfjustis closed this as completed Jan 9, 2025
@kfjustis
Copy link
Author

kfjustis commented Jan 9, 2025

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.

@kfjustis kfjustis reopened this Jan 9, 2025
@Geokureli
Copy link
Member

Geokureli commented Jan 10, 2025

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

@DetectiveBaldi
Copy link
Contributor

Have you checked camera.pixelPerfectRender and object.pixelPerfectRender? I believe it affects object positioning

@kfjustis
Copy link
Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants