2022-03-11 00:21:50 +02:00

47 lines
936 B
Lua

local druid = require("druid.druid")
local function on_drag_callback(self, dx, dy)
self.position.x = self.position.x + dx
self.position.y = self.position.y + dy
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
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)
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