This example shows how to make a game object move to the position the user clicks.
function init(self) msg.post(".", "acquire_input_focus") self.moving = false end local function landed(self) self.moving = false end function on_input(self, action_id, action) if action_id == hash("click") and action.pressed then if not self.moving then msg.post("#label", "disable") self.moving = true pos = vmath.vector3(action.x, action.y, 0) go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, pos, go.EASING_LINEAR, 0.5, 0, landed) end end end
self(the current script component) to indicate if the game object is moving or not.
movingflag is not set.
vector3) where the user clicked.
pos. When the animation is done, call the function
landed()is called when the animation is done. It just resets the
movingflag so subsequent clicks will result in a new movement.
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.