spaceship1.script 780 B

123456789101112131415161718
  1. local function landed(self) -- <2>
  2. label.set_text("#speech", "I'm there!")
  3. msg.post("spaceship2#script", "i'm there")
  4. end
  5. function on_message(self, message_id, message, sender)
  6. if message_id == hash("go to") then -- <1>
  7. label.set_text("#speech", "Ok...")
  8. go.animate(".", "position", go.PLAYBACK_ONCE_FORWARD, message.position, go.EASING_INOUTCUBIC, 1, 0, landed)
  9. end
  10. end
  11. --[[
  12. 1. If someone sends us a "go to" message, set the speech label text and animate to the position supplied
  13. in the message data. At the end of animation, call the function `landed()`
  14. 2. This function is called when the position animation is completed. It sets the speech label text and then
  15. sends a message called "i'm there" to the component "script" in the "spaceship2" game object.
  16. --]]