here is the controller script
function init(self)
if not go.get("#cursor", "acquire_input_focus") then
self.forward_input = true
msg.post(".", "acquire_input_focus")
end
cursor.listen(msg.url("#cursor"), cursor.DRAG_START, function(message_id, message)
print("drag")
-- prevent dragging of blue aliens
if message.group == hash("blue") then
print("prevent")
return true
end
end)
end
function on_input(self, action_id, action)
if self.forward_input then
msg.post("#cursor", "input", { action_id = action_id, action = action })
end
end
function on_message(self, message_id, message, sender)
if message_id == cursor.OVER then
print("Cursor over", message.id, message.group, message.x, message.y)
elseif message_id == cursor.OUT then
print("Cursor out", message.id, message.group, message.x, message.y)
elseif message_id == cursor.PRESSED then
print("Pressed", message.id, message.group, message.x, message.y)
elseif message_id == cursor.RELEASED then
print("Released", message.id, message.group, message.x, message.y)
elseif message_id == cursor.CLICKED then
print("Clicked", message.id, message.group, message.x, message.y)
elseif message_id == cursor.DRAG_START then
print("Drag started", message.id, message.group, message.x, message.y)
elseif message_id == cursor.DRAG_END then
print("Drag ended", message.id, message.group, message.x, message.y)
elseif message_id == cursor.DRAG then
print("Drag", message.id, message.group, message.x, message.y, message.dx, message.dy)
end
end
and here is the card script (attached to the thing i want to drag)
local cursor = require "in.cursor"
local function shake(self)
go.cancel_animations(".", "scale.x")
go.cancel_animations(".", "scale.y")
go.set_scale(self.initial_scale)
local scale = go.get_scale()
go.set_scale(scale * 1.2)
go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, scale.x, go.EASING_OUTELASTIC, 0.8)
go.animate(".", "scale.y", go.PLAYBACK_ONCE_FORWARD, scale.y, go.EASING_OUTELASTIC, 0.8, 0, function()
go.set_scale(self.initial_scale)
end)
end
function init(self)
self.initial_scale = go.get_scale()
-- msg(".","acquire_input_focus")
end
function on_message(self, message_id, message, sender)
if message_id == cursor.OVER then
self.over_pos = go.get_position()
go.set_position(vmath.vector3(self.over_pos.x, self.over_pos.y, 1))
go.animate("#face_sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 1.5, go.EASING_OUTQUAD, 0.1)
elseif message_id == cursor.OUT then
local pos = go.get_position()
go.set_position(vmath.vector3(pos.x, pos.y, self.over_pos.z))
go.animate("#face_sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_OUTQUAD, 0.1)
elseif message_id == cursor.PRESSED or message_id == cursor.RELEASED then
shake(self)
print("shake")
end
end
as you can see i copied the same code as the example you guys provided