HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.97k stars 434 forks source link

No publicly accessible functionality to get global screen position in FlxPointer #3200

Closed 01010111 closed 2 months ago

01010111 commented 3 months ago

Code snippet reproducing the issue:

package;

import flixel.FlxG;
import flixel.FlxState;

class PlayState extends FlxState
{
    override public function create()
    {
        super.create();
        camera.setSize(800, 800);
        camera.setPosition(-(800 - FlxG.width)/2, -(800 - FlxG.height)/2);
    }

    override public function update(elapsed:Float)
    {
        super.update(elapsed);
        trace(camera.x, camera.y);
        trace(FlxG.mouse.getScreenPosition());
    }
}

Observed behavior:

When putting the mouse cursor at the top-left position on flixel's screen, trace(camera.x, camera.y is returning -80, -160 and trace(FlxG.mouse.getScreenPosition() is returning (x: 80 | y: 154)

Expected behavior:

When putting the mouse cursor at the top-left position on flixel's screen, trace(camera.x, camera.y should return -80, -160 and trace(FlxG.mouse.getScreenPosition() should return (x: 0 | y: 0)

(also note that assuming that this is also affected by #3199

01010111 commented 3 months ago

Looks like there was some misunderstanding on my part, I just don't think there's any publicly accessible functionality within FlxPointer to get the global screen position of the mouse, changing the issue name to reflect that!

Geokureli commented 2 months ago

Fixed via https://github.com/HaxeFlixel/flixel/pull/3211