Automatically transform cursor hotspot user asks to flip cursor image #17540
+83
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
scale
transform option exists. It's harder for users to transform the hotspot themselves when usingscale
because they'd need to look up the image to get its dimensions. Instead, we let Bevy handle the hotspot transforms and make thehotspot
field the "original/source" hotspot.Solution
Testing
cargo run --example custom_cursor_image --features=custom_cursor
.bevy_cursor_kit
crate, which I think is a good illustration of the reason for this PR.Y
, the cursor flips.bevy@main
before this PR, notice how the hotspot is wrong after flipping and no longer hovering the button. The arrow head and hotspot are no longer synced.Y
and the cursor arrow head is in the correct position on the screen and still hovering the button. Speaking back to the objective listed at the start: The user originally defined the source hotspot for the arrow. Later, they decide they want to flip the cursor vertically: It's nice that Bevy can automatically flip the source hotspot for them at the same time it flips the source image.First video (main):
before.mov
Second video (this PR):
after.mov