local druid = require("druid.druid") local function on_drag_callback(self, dx, dy, total_x, total_y) self.position.x = self.position.x + dx self.position.y = self.position.y + dy print("Total drag:", total_x, total_y) gui.set_position(self.box, self.position) end local function on_drag_end(self) self.position.x = 0 self.position.y = 170 gui.animate(self.box, "position", self.position, gui.EASING_OUTSINE, 0.3) end local function on_drag_toggle(self) self.drag:set_enabled(not self.drag:is_enabled()) end function init(self) self.druid = druid.new(self) self.box = gui.get_node("icon_box") self.position = gui.get_position(self.box) self.drag = self.druid:new_drag("drag_node", on_drag_callback) self.drag.on_drag_end:subscribe(on_drag_end, self) self.druid:new_button("button_drag/button", on_drag_toggle) end function final(self) self.druid:final() end function update(self, dt) self.druid:update(dt) end function on_message(self, message_id, message, sender) self.druid:on_message(message_id, message, sender) end function on_input(self, action_id, action) return self.druid:on_input(action_id, action) end