ship.script 602 B

123456789101112131415161718
  1. function init(self)
  2. -- Animate automatic player position
  3. go.animate(".", "position.x", go.PLAYBACK_LOOP_PINGPONG, 620, go.EASING_LINEAR, 6.0)
  4. -- Create a timer to tick every 0.25 second:
  5. timer.delay(0.25, true, function()
  6. -- Create a simple bullet bullet using the factory
  7. local bullet_id = factory.create("#bulletfactory", go.get_position())
  8. -- Animate the created bullet towards top of screen, where it is deleted
  9. if bullet_id then
  10. go.animate(bullet_id, "position.y", go.PLAYBACK_ONCE_FORWARD, 600, go.EASING_LINEAR, 1, 0, function()
  11. go.delete(bullet_id)
  12. end)
  13. end
  14. end)
  15. end