Alternative To Draggable Behavior

The draggable behavior is not working, or not working as you expect? Because it should work in both platforms :confused:

Anyway, to simulate the draggable behavior over an object, the idea is to “mark”(?) the object that is under the cursor when you press the mouse button, then move the marked object to the cursor position while the button is hold, finally unmark the object when the button is released:

[code]Conditions: Left button is pressed
Trigger once
Actions: No actions
// Sub-event
Conditions: Cursor is over DraggableObject
Actions: Do = 1 to the variable “dragging” of DraggableObject

Conditions: Variable “dragging” of DraggableObject is = 1
Actions: Do = MouseX(); MouseY() to the position of DraggableObject

Conditions: Left button is released
Actions: Do = 0 to the variable “dragging” of DraggableObject[/code]
If you want to know why I use a sub event here, please check this: [url]If clicked condition - #2 by Lizard-13]

This way the object will be placed (from its Origin point) exactly over the cursor position, so maybe you’ll want to add an “OffsetX” and “OffsetY” variables, that save the initial offset between the object position and the cursor, and add the offset while the object follow the cursor :wink:

1 Like