bee.script 818 B

12345678910111213141516171819202122232425
  1. function init(self)
  2. msg.post(".", "acquire_input_focus")
  3. go.animate(".", "position.x", go.PLAYBACK_LOOP_PINGPONG, 2000, go.EASING_INOUTQUAD, 10) -- <1>
  4. msg.post("camera", "follow") -- <2>
  5. self.follow = true -- <3>
  6. end
  7. function on_input(self, action_id, action)
  8. if action_id == hash("touch") and action.pressed then -- <4>
  9. self.follow = not self.follow
  10. if self.follow then
  11. msg.post("camera", "follow")
  12. else
  13. msg.post("camera", "unfollow")
  14. end
  15. end
  16. end
  17. --[[
  18. 1. Move this game object back and forth across the scene.
  19. 2. Send a message to the camera game object telling it to follow this game object.
  20. 3. Keep track of if the camera is following this game object or not.
  21. 4. Toggle between following and not following the game object when the left mouse button is clicked or the screen is touched.
  22. --]]