Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- In storyboard scene function
- -- group is self.view
- -- Colorspace changing function
- local function HSVtoRGB(h, s, v)
- local r,g,b
- local i
- local f,p,q,t
- if s == 0 then
- r = v
- g = v
- b = v
- return math.round(r * 255), math.round(g * 255), math.round(b * 255)
- end
- h = h / 60;
- i = math.floor(h);
- f = h - i;
- p = v * (1 - s);
- q = v * (1 - s * f);
- t = v * (1 - s * (1 - f));
- if i == 0 then
- r = v
- g = t
- b = p
- elseif i == 1 then
- r = q
- g = v
- b = p
- elseif i == 2 then
- r = p
- g = v
- b = t
- elseif i == 3 then
- r = p
- g = q
- b = v
- elseif i == 4 then
- r = t
- g = p
- b = v
- elseif i == 5 then
- r = v
- g = p
- b = q
- end
- return math.round(r * 255), math.round(g * 255), math.round(b * 255)
- end
- -- Particle generation
- local mRandom = math.random
- local function newExplosion(params)
- local gr, x, y = params.g, params.x, params.y
- local star, r, g, b
- local s = 1
- if params.big then
- s = 4
- end
- for i = 1, mRandom(5 * s, 15 * s) do
- star = display.newRect(gr, x - 8, y - 4, 8, 8)
- r, g, b = HSVtoRGB(mRandom(1, 359), 1, 1)
- star:setFillColor(r, g, b)
- star.blendMode = 'add'
- transition.to(star, {time = mRandom(100, 500), x = mRandom(-30 * s, 30 * s), y = mRandom(-50 * s, 50 * s), alpha = -1, delta = true, onComplete = function (target) display.remove(target) end})
- end
- end
- newExplosion{g = group, x = 160, y = 240}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement