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

Added deltaX and deltaY properties to FlxMouse. #2709

Merged
merged 1 commit into from
Dec 31, 2022

Conversation

EliteMasterEric
Copy link
Contributor

This function makes it easy to compare how the mouse has moved since the last update(). This makes use of the internal _prevX and _prevY values, previously private and inaccessible to the user.

Behaving somewhat similarly to wheel, these properties provide the following:

  • diffX: The distance the mouse has moved horizontally since the previous update.
  • diffY: The distance the mouse has moved vertically since the previous update.
  • diffScreenX: The distance the mouse has moved in screen space horizontally since the previous update.
  • diffScreenY: The distance the mouse has moved in screen space vertically since the last update.

This pull request is a rewrite of #2644, which was abandoned due to a faulty Git rebase.

@Geokureli
Copy link
Member

Geokureli commented Dec 31, 2022

x, y, screenX and screenY are defined in FlxPointer which FlxMouse extends, might as well add these properties to FlxPointer instead of FlxMouse

@Geokureli
Copy link
Member

Geokureli commented Dec 31, 2022

on second thought, I see that _prevX was already defined in FlxMouse rather than FlxPointer, so those would need to be moved to the super class.

this makes me wonder if adding 4 new floats to every pointer, by default, is too much overhead, so for now let's just keep it in FlxMouse and revisit this after I finish a tool I'm working on that may help optimize this

@Geokureli Geokureli merged commit 5422ec9 into HaxeFlixel:dev Dec 31, 2022
@EliteMasterEric EliteMasterEric deleted the feature/mouse-delta branch December 31, 2022 04:09
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

Successfully merging this pull request may close these issues.

2 participants