Hi,
I’m using the cursor script together with the orthographic camera, and I’m having some issues.
I can’t get game objects to receive the messages from the cursor. The cursor itself gets the messages perfectly when clicking on objects with a collider though. I got that working after making my own copy of cursor.script
and adjusting the handle_input()
function to use camera.screen_to_world()
on the action position. Are there any other adjustments I need to be doing to get these two plugins to work together? I’m using FIXED_ZOOM
projection with a zoom of 4
on the camera.
This is my game object script where I’m listening to messages, which don’t seem to be run at all:
local cursor = require "in.cursor"
function on_message(self, message_id, message, sender)
pprint(message)
if message_id == cursor.OVER then
print("over pickup")
elseif message_id == cursor.OUT then
print("out pickup")
elseif message_id == cursor.PRESSED or message_id == cursor.RELEASED then
print("pressed pickup")
end
end
And this is my cursor controller script, which actually receives messages:
local cursor = require "in.cursor"
function init(self)
if not go.get("#cursor", "acquire_input_focus") then
self.forward_input = true
msg.post(".", "acquire_input_focus")
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.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)
end
end
Tell me if you want some more information. Thanks!