burst.lua 528 B

12345678910111213141516171819202122232425
  1. local burst = lib.object.create()
  2. function burst:init()
  3. self.alpha = 1
  4. lib.flux.to(self, .5, { alpha = 0 })
  5. :ease('cubicout')
  6. :oncomplete(function()
  7. self:unbind()
  8. app.context:removeObject(self)
  9. end)
  10. end
  11. function burst:bind()
  12. return {
  13. app.context.view.draw
  14. :subscribe(function()
  15. g.setColor(160, 255, 140, self.alpha * 255)
  16. g.ellipse('fill', self.position.x, self.position.y, self.radius, self.radius / 2)
  17. return -self.position.y
  18. end)
  19. }
  20. end
  21. return burst