You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mouse Click Question plus Two features request [startDrag & stopDrag node] #363
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:
`
This is how the draggable object is to be setup.
Area2D
└AnimatedSprite2D [or Sprite2D]
└CollisionShape2D [inside it contains RectangleShape2D]
Create a script for the Area2D node, connect its input_event~ signal to it.
Enter these in:
extends Area2D
var selected:bool = false
var mouse_offset:Vector2 = Vector2(0,0)
func _process(delta: float) -> void:
if selected:
followMouse()
func followMouse() -> void:
position = get_global_mouse_position() + mouse_offset
func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.is_pressed():
mouse_offset = position - get_global_mouse_position()
#If you are using touch and are getting major positional offset error/bug:
#In the Project Settings, uncheck "Emulate Mouse From Touch", this should fix it, don't do anything else.
selected = true
else:
selected = false
`
In Flash, all one have to do is:
on (pressed)
{startDrag();}
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
Can we have a startDrag and stopDrag node for both 2D and 3D objects in Block Code? The kids are going to love this simplicity because it could have been this simple, it was done 19 years ago!
Can this sanity be restored to Godot using Block Code?
changed the title [-]Mouse Click Question plus Two features request[/-][+]Mouse Click Question plus Two features request [startDrag & stopDrag node][/+]on Jan 25, 2025
Activity
[-]Mouse Click Question plus Two features request[/-][+]Mouse Click Question plus Two features request [startDrag & stopDrag node][/+]