I made some mouse cursors to communicate more clearly the rotate vs. move options. Using temporary artwork for now, based on icons by Amin Hidayat. I made the arrow more pointy and gave each cursor a fill. Slowly getting used to GIMP.
I’m having a problem with the cursor flickering when the mouse is moved. I created a CursorManager
singleton so I could debounce changes to the cursor but it turned out I’m not calling it repeatedly anyway.
Looks like it’s just flicking back and forth between my custom arrow cursor and the cursor I have set when I move the mouse over the blocks. What if I don’t set a custom arrow cursor?
It flickers between that and the custom cursor.
But only on mouse over. The rest of the canvas is fine… I guess because that’s using the regular mouse cursor.
Something is setting it back to arrow… this is not what I want to be spending my time on.
I duplicated the issue in a bare bones example:
extends Node2D
var is_left: bool = false
func _process(delta: float) -> void:
if get_global_mouse_position()[0] < 100:
if !is_left:
is_left = true
DisplayServer.cursor_set_shape(DisplayServer.CURSOR_DRAG)
else:
if is_left:
is_left = false
DisplayServer.cursor_set_shape(DisplayServer.CURSOR_POINTING_HAND)
Doesn’t even need custom cursors, just changing the cursor doesn’t seem to work. It will update for one frame and then revert to an arrow.
I wonder if it’s platform-specific.
…
Okay, found it. DisplayServer
seems to be a lower-level class that’s not meant to be used directly. I don’t know where I found DisplayServer
but looks like the correct method for changing the cursor is to use Input
:
extends Node2D
var is_left: bool = false
func _process(delta: float) -> void:
if get_global_mouse_position()[0] < 100:
if !is_left:
is_left = true
Input.set_default_cursor_shape(Input.CURSOR_DRAG)
else:
if is_left:
is_left = false
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
This works as expected. Phew!
Glad that’s sorted.
New problem. Sometimes a block will revert even when it looks valid.
The above reverts. It won’t allow it to be placed there even though the block is not showing up in the red “forbidden” state.
After some investigation I found this doesn’t revert.
The difference is the mouse position. Looks like I’m testing for the collision before snapping so let’s fix that real quick.
Alright, so that little prototype was successful, I’d say. Much more usable than the puzzle that I released last week. So now it’s time to integrate it back into the prototype with the mirrors and emitters and everything.
…
I updated the puzzle as well.
A couple things to work on:
- When dragging a mirror, both the original mirror and the ghost are still redirecting lasers. Should only the ghost work? Or only the actual?
- I should make a few shapes that I can use as walls. Just make them black silhouettes. Then I can arrange them around the edges as well as where the walls are currently.
…
K, I took care of the first issue. I was trying to set a flag for enabled/disabled which the Laser
class can read when it’s doing collision detection. Then I realized I don’t need that, I can just update the collision layer, i.e., remove the ghost mirror from the collision layer. Easy peasy.
I also got feedback that determining which parts of the mirror are used to move vs. rotate is difficult so I added a separate sprite for hover.
Normally that dotted grip pattern is used for drag. I originally had it in the middle instead of on the edges but something told me to draw attention to the rotate region rather than the move region.
Here’s a ghost mirror having no effect on the laser beam:
While rotating it still redirects the laser, except during collision.
Hopefully that will make it more clear. We’ll see what friends/family say.
Next up is making better walls, reckon.