alestane

Sandstorm flow

Apr 19th, 2013
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local sandstorm = {}
  2.  
  3. local function moveParticles()
  4.     local group = sandstorm.group
  5.     for i = 1, group.numChildren do
  6.         local particle = group[i]
  7.         particle.x = particle.x + math.random(-1, 1)
  8.     particle.y = particle.y + 1
  9.     end
  10. end
  11.  
  12. function sandstorm.new(quantity)
  13.     local random = math.random
  14.     sandstorm.group = display.newGroup()
  15.     local group = sandstorm.group
  16.     for i = 1, quantity do
  17.         local particle = group[i]
  18.         particle = display.newRect(group, 0, 0, 1, 1)
  19.         particle:setReferencePoint(display.TopLeftReferencePoint)
  20.         particle.x, particle.y = random(display.screenLeft, display.screenRight), random(display.screenTop, display.screenBottom)
  21.         particle:setFillColor(random(232, 255) , random(183, 213), random(117, 147))
  22.     end
  23.     group:addEventListener("enterFrame", moveParticles)
  24.     return group
  25. end
  26.  
  27. return sandstorm
Advertisement
Add Comment
Please, Sign In to add comment