Advertisement
alestane

Fireworks

Feb 29th, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.08 KB | None | 0 0
  1. function flair(parent, x, y, size)
  2.     local self = display.newGroup()
  3.     parent:insert(self)
  4.     self.x, self.y = x, y
  5.     for i=1,30 do
  6.         local angle, radius, size, spin, bright = math.random() * 2 * math.pi, math.random(size * 2/3, size), math.random(size / 48, size / 16), math.random(180, 720), math.random(2) < 2 and "add" or "normal"
  7.         local star = display.newRect(self, 0, 0, size, size) do
  8.             star.x, star.y = math.cos(angle) * radius, math.sin(angle) * radius
  9.             star.rotation = math.random(360)
  10.             star.blendMode = bright
  11.             transition.to(star, {time=1500, transition=easing.inQuad, delta=true; rotation=spin})
  12.         end
  13.     end
  14.     transition.to(self, {time=1500, transition=easing.inQuad; alpha=0, y=self.y + self.height * 0.5 * self.yScale})
  15.     local expansion = 1.5
  16.     transition.to(self, {time=1500, onComplete=display.remove, transition=easing.outExpo; xScale=1.5, yScale=1.5})
  17.     return self
  18. end
  19.  
  20. Runtime:addEventListener('tap',
  21.     function(event)
  22.         flair(display.getCurrentStage(), event.x, event.y, display.contentWidth / 8 * event.numTaps)
  23.         return true
  24.     end
  25. )
  26.  
  27. system.activate "multitouch"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement