Mouse Click Question plus Two features request [startDrag & stopDrag node] #372
-
Question 3: Can we, like Flash, have a startDrag and StopDrag node? In case you might be worrying it is "extra node", for consistency sake you already have the stop and play sound wrapper node which makes it really easy to play sound. Currently in Godot, this is the amount of Drama you need just to click and drag a node: Create a script for the Area2D node, connect its input_event~ signal to it. Enter these in: var selected:bool = false func _process(delta: float) -> void: func followMouse() -> void: func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void: In Flash, all one have to do is: That's like...two lines of code....19 years ago, somewhere along the line complexity = cool? Yap, startDrag() and stopDrag(), that's it, who would have thought it could have been that simple ;p Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
For mouse click, you can add a new action in Project Settings. Then: This is valid for the GDScript in your image too. Here Block Coding can teach you to use actions if you press "Show Generated Script": extends SimpleEnding
func _process(delta):
if (Input.is_action_just_pressed('click!')):
game_over('WIN') UPDATE: For dragging, you can use the new mouse position block along with the action above. It could also be nice to explore having high-level blocks for this. In a SimpleDragDrop custom node, for instance. |
Beta Was this translation helpful? Give feedback.
For mouse click, you can add a new action in Project Settings. Then:
This is valid for the GDScript in your image too. Here Block Coding can teach you to use actions if you press "Show Generated Script":
UPDATE:
For dragging, you can use the new mouse position block along with the action above. It could also be nice to explore having high-level blocks for this. In a SimpleDragDrop custom node, for instance.