Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sandstorm = {}
- local function moveParticles()
- local group = sandstorm.group
- for i = 1, group.numChildren do
- local particle = group[i]
- particle.x = particle.x + math.random(-1, 1)
- particle.y = particle.y + 1
- end
- end
- function sandstorm.new(quantity)
- local random = math.random
- sandstorm.group = display.newGroup()
- local group = sandstorm.group
- for i = 1, quantity do
- local particle = group[i]
- particle = display.newRect(group, 0, 0, 1, 1)
- particle:setReferencePoint(display.TopLeftReferencePoint)
- particle.x, particle.y = random(display.screenLeft, display.screenRight), random(display.screenTop, display.screenBottom)
- particle:setFillColor(random(232, 255) , random(183, 213), random(117, 147))
- end
- group:addEventListener("enterFrame", moveParticles)
- return group
- end
- return sandstorm
Advertisement
Add Comment
Please, Sign In to add comment