bee.script 667 B

123456789101112131415161718
  1. function init(self)
  2. -- send input events to this script
  3. msg.post(".", "acquire_input_focus")
  4. end
  5. function on_input(self, action_id, action)
  6. if action_id == hash("touch") and action.pressed then
  7. -- convert mouse/touch screen position to world position
  8. local screen = vmath.vector3(action.screen_x, action.screen_y, 0)
  9. local world = camera.screen_to_world(screen, "#camera")
  10. -- alternative using camera.screen_xy_to_world(x, y, camera)
  11. -- local world = camera.screen_xy_to_world(action.screen_x, action.screen_y, v)
  12. -- animate bee to new world position
  13. go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, world, go.EASING_LINEAR, 0.5, 0)
  14. end
  15. end