This example shows how a physics trigger is used to trigger an event. In this case the bunny sprite is disabled and enabled.
The setup consists of two game objects.
TRIGGER. A box Shape is added to the components.
DYNAMIC. A sphere Shape matching the sprite image is added to the components.
function init(self) local pos = go.get_position() go.animate(".", "position.x", go.PLAYBACK_LOOP_PINGPONG, pos.x + 600, go.EASING_INOUTSINE, 6) end function on_message(self, message_id, message, sender) if message_id == hash("trigger_response") then if message.enter then msg.post("#sprite", "disable") else msg.post("#sprite", "enable") end end end
messagedata table contains a field
enterthat is set to
truewhen the trigger event signals that the trigger shape was entered. On exiting the trigger, this field is
If you want to play with these examples, you can get the project on Github.
Do you want to see more examples? Why not write a few yourself and submit a pull request? We love contributions.