HaxeFlixel / flixel-ui

GUI library for HaxeFlixel

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FIX] FlxUICursor mouse coordinates do not scroll with camera

DigiEggz opened this issue · comments

When moving the camera, button coordinates aren't properly updated for mouse controls within FlxUICursor.

When moving to the top of the map, the buttons work correctly when hovering the mouse. Here I've hovered over Button 2:
1

When moving downward, the coordinates of the button do not move for the FlxUICursor. Hovering over the original button location instead causes the cursor to move. Note the position of the cursor for hovering over Button 2:
2

I've attached source code with a basic project that demonstrates the error:
UI Demo.zip

The problem lies within the update() for FlxUICursor. I was able to fix the scroll issue by setting jumpToXY() to use the mouse's screenX and screenY instead of its x and y.

#if FLX_MOUSE
if (lastMouseX != FlxG.mouse.x || lastMouseY != FlxG.mouse.y)
{
	var oldVis = visible;
	jumpToXY(FlxG.mouse.screenX, FlxG.mouse.screenY);
	visible = oldVis;

	#if FLX_MOUSE
	lastMouseX = FlxG.mouse.x;
	lastMouseY = FlxG.mouse.y;
	#end
}
#end

If this is an acceptable fix, I'll create a pull request.