- Only one collection is loaded
- This is the script that is triggered within the gameobject “x box”:
go.property("paused", false)
function on_message(self, message_id, message, sender)
if message_id == hash("trigger_response") and message.group == hash("clicker") then
print("X CLICKED")
msg.post("brain#script", "release_input_focus") -- stops movement
msg.post("/gamemenu#script", "menuenabled") -- makes menu appear
elseif message_id == hash("trigger_response") and message.group == hash("roller") and message.enter then
print("X rollED")
elseif message_id == hash("trigger_response") and message.group == hash("roller") and not message.enter then
print("X UNrollED")
end
function init(self)
end
end
-This is the script in the gamemenu object.
function init(self)
go.set("#sprite", "tint.w", 0)
end
function on_message(self, message_id, message, sender)
print("menuenabled")
go.set(".", "position.x", 500)
go.animate("#sprite", "tint.w", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_INOUTSINE, 0.2)
go.animate(".", "position.x", go.PLAYBACK_ONCE_FORWARD, 600, go.EASING_INOUTSINE, 0.2)
end
script in the roller object:
function init(self)
print("acquired")
msg.post(".", "acquire_input_focus")
cameraposition = vmath.vector3(0, 0, 0)
end
function on_input(self, action_id, action)
--this moves the collider
go.set_position(vmath.vector3(action.x, action.y, 0))
--this creates the clicker
if action_id == hash("click") and action.pressed then
local p=(vmath.vector3(action.x, action.y, 0))
factory.create("#clickerfactory", p+cameraposition)
print("got clicked")
end
end
- script in the clicker object
local clicktime= 0
function update(self, dt)
if clicktime<3 then
go.delete(".")
end
end
Just to be clear: a collision between the roller and the gamemenu object triggers the behaviour in the gameobject x box´s script.