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

FlxPointer.getScreenPosition is returning impossible numbers #3199

Open
01010111 opened this issue Jul 4, 2024 · 2 comments
Open

FlxPointer.getScreenPosition is returning impossible numbers #3199

01010111 opened this issue Jul 4, 2024 · 2 comments

Comments

@01010111
Copy link
Contributor

01010111 commented Jul 4, 2024

  • Haxe version: 4.3.2
  • Flixel version: 5.8.0
  • OpenFL version: 9.3.3
  • Lime version: 8.1.2
  • Affected targets: html5, ?

Code snippet reproducing the issue:

package;

import flixel.FlxG;
import flixel.FlxState;

class PlayState extends FlxState
{
	override public function update(elapsed:Float)
	{
		super.update(elapsed);
		trace(FlxG.mouse.getScreenPosition());
	}
}

It's also useful to update openfl-content div's styling:

#openfl-content {
    background: #000000;
    width: 640px;
}

Observed behavior:

When placing the cursor at the top-left most position on the screen, trace(FlxG.mouse.getScreenPosition() is returning (x: 0 | y: -4)

Expected behavior:

When placing the cursor at the top-left most position on the screen, trace(FlxG.mouse.getScreenPosition() should return (x: 0 | y: 0)

@01010111
Copy link
Contributor Author

01010111 commented Jul 4, 2024

traced this back to openFL's Stage.__mouseY so I think it's probably safe to assume this isn't a flixel issue?

@Geokureli
Copy link
Member

Geokureli commented Jul 8, 2024

What is going on here? is this a way to resize the game?

width: 640px;

Here are my results:

  • getScreenPosition and getPositionInCameraView: (cam.viewMarginLeft, cam.viewMarginTop) is at the top-left of the camera and (cam.viewMarginRight, cam.viewMarginBottom) is the bottom-right of the camera
  • getWorldPosition: self explanatory
  • _globalScreenX/Y: (0, 0) is at the top-left of the FlxGame, (FlxG.width, FlxG.height) is at the bottom-right of the FlxGame

What I'm working on (or thinking about doing):

  • getGamePosition: Same a _globalScreen, I believe this is what you're after
  • getWindowPosition: (0, 0) is the top-left of the window, (stage.StageWidth, stage.StageHeight) is the bottom right of the window
  • getViewPosition, viewX and viewY: Replacement for the confusing "screen" fields and getPositionInCameraView

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

2 participants