+ opacity transition support to particles

This commit is contained in:
FajsiEx 2021-11-17 19:54:26 +01:00
parent fd63ba6963
commit 4629ff6bbe
1 changed files with 48 additions and 23 deletions

View File

@ -38,9 +38,10 @@ local outroTransitionTextBlurAlpha = 0;
local particles = { local particles = {
green_dot_one = { green_dot_one = {
texture = particleGreenDot1Image, texture = particleGreenDot1Image,
opacity = 1,
startX = 1280, startX = 1280,
finishX = 380, finishX = 380,
currentX = 1280, xPos = 1280,
yPos = 660, yPos = 660,
width = 235*0.5, width = 235*0.5,
height = 235*0.5, height = 235*0.5,
@ -49,9 +50,10 @@ local particles = {
}, },
green_dot_two = { green_dot_two = {
texture = particleGreenDot2Image, texture = particleGreenDot2Image,
opacity = 1,
startX = 1280, startX = 1280,
finishX = 70, finishX = 70,
currentX = 1280, xPos = 1280,
yPos = 610, yPos = 610,
width = 128*0.5, width = 128*0.5,
height = 128*0.5, height = 128*0.5,
@ -60,9 +62,10 @@ local particles = {
}, },
blue_ring = { blue_ring = {
texture = particleBlueRingImage, texture = particleBlueRingImage,
opacity = 1,
startX = 1280, startX = 1280,
finishX = 65, finishX = 65,
currentX = 1280, xPos = 1280,
yPos = 620, yPos = 620,
width = 229*0.5, width = 229*0.5,
height = 229*0.5, height = 229*0.5,
@ -71,20 +74,24 @@ local particles = {
}, },
large_rainbow_ring = { -- needs opacity and scale transitions large_rainbow_ring = { -- needs opacity and scale transitions
texture = particleLargeRainbowRingImage, texture = particleLargeRainbowRingImage,
opacity = 0,
startOpacity = 0,
finishOpacity = 1,
startX = (1080/2-(2160*0.675)/2), startX = (1080/2-(2160*0.675)/2),
finishX = (1080/2-(2160*0.675)/2), finishX = (1080/2-(2160*0.675)/2),
currentX = (1080/2-(2160*0.675)/2), xPos = (1080/2-(2160*0.675)/2),
yPos = (680-(2273*0.675)/2) + 100, yPos = (680-(2273*0.675)/2) + 100,
width = 2160*0.675, width = 2160*0.675,
height = 2273*0.675, height = 2273*0.675,
startTime = 0.25, startTime = 0.25,
duration = 0.6 duration = 0.6,
}, },
red_ball = { -- needs opacity transition red_ball = { -- needs opacity transition
texture = particleRedBallImage, texture = particleRedBallImage,
startX = -150, startOpacity = 0,
finishX = -150, finishOpacity = 1,
currentX = -150, opacity = 0,
xPos = -150,
yPos = 500, yPos = 500,
width = 787*0.5, width = 787*0.5,
height = 818*0.5, height = 818*0.5,
@ -93,9 +100,10 @@ local particles = {
}, },
red_ring = { red_ring = {
texture = particleRedRingImage, texture = particleRedRingImage,
opacity = 1,
startX = -600, startX = -600,
finishX = 590, finishX = 590,
currentX = -600, xPos = -600,
yPos = 460, yPos = 460,
width = 1051*0.5, width = 1051*0.5,
height = 1081*0.5, height = 1081*0.5,
@ -104,9 +112,10 @@ local particles = {
}, },
small_yellow_ring_1 = { small_yellow_ring_1 = {
texture = particleSmallYellowRing1Image, texture = particleSmallYellowRing1Image,
opacity = 1,
startX = 1280, startX = 1280,
finishX = -170, finishX = -170,
currentX = 1280, xPos = 1280,
yPos = 620, yPos = 620,
width = 579*0.5, width = 579*0.5,
height = 557*0.5, height = 557*0.5,
@ -115,9 +124,10 @@ local particles = {
}, },
small_yellow_ring_2 = { small_yellow_ring_2 = {
texture = particleSmallYellowRing2Image, texture = particleSmallYellowRing2Image,
opacity = 1,
startX = 1280, startX = 1280,
finishX = 140, finishX = 140,
currentX = 1280, xPos = 1280,
yPos = 590, yPos = 590,
width = 436*0.5, width = 436*0.5,
height = 392*0.5, height = 392*0.5,
@ -126,9 +136,10 @@ local particles = {
}, },
small_rainbow_ring = { small_rainbow_ring = {
texture = particleSmallRainbowRingImage, texture = particleSmallRainbowRingImage,
opacity = 1,
startX = 1280, startX = 1280,
finishX = -380, finishX = -380,
currentX = 1280, xPos = 1280,
yPos = 450, yPos = 450,
width = 1117*0.5, width = 1117*0.5,
height = 1117*0.5, height = 1117*0.5,
@ -137,9 +148,10 @@ local particles = {
}, },
yellow_ring = { yellow_ring = {
texture = particleYellowRingImage, texture = particleYellowRingImage,
opacity = 1,
startX = -600, startX = -600,
finishX = 650, finishX = 650,
currentX = -600, xPos = -600,
yPos = 370, yPos = 370,
width = 1401*0.5, width = 1401*0.5,
height = 1398*0.5, height = 1398*0.5,
@ -181,15 +193,28 @@ local tickTransitions = function (deltaTime)
) )
for particleName, particle in pairs(particles) do for particleName, particle in pairs(particles) do
if (outroTransitionScale < particle.startTime) then
particle.currentX = particle.startX;
elseif (outroTransitionScale >= particle.startTime + particle.duration) then
particle.currentX = particle.finishX;
else
local transScale = Easing.outQuad(math.min(1, (outroTransitionScale-particle.startTime)/particle.duration)); local transScale = Easing.outQuad(math.min(1, (outroTransitionScale-particle.startTime)/particle.duration));
if (particle.finishX) then -- If x position want to have anim
if (outroTransitionScale < particle.startTime) then
particle.xPos = particle.startX;
elseif (outroTransitionScale >= particle.startTime + particle.duration) then
particle.xPos = particle.finishX;
else
local xDiff = particle.finishX - particle.startX; local xDiff = particle.finishX - particle.startX;
particle.currentX = particle.startX + xDiff*transScale; particle.xPos = particle.startX + xDiff*transScale;
end
end
if (particle.finishOpacity) then
if (outroTransitionScale < particle.startTime) then
particle.opacity = particle.startOpacity;
elseif (outroTransitionScale >= particle.startTime + particle.duration) then
particle.opacity = particle.finishOpacity;
else
local opacityDiff = particle.finishOpacity - particle.startOpacity;
particle.opacity = particle.startOpacity + opacityDiff*transScale;
end
end end
end end
@ -210,12 +235,12 @@ local drawParticles = function ()
for particleName, particle in pairs(particles) do for particleName, particle in pairs(particles) do
gfx.BeginPath(); gfx.BeginPath();
gfx.ImageRect( gfx.ImageRect(
particle.currentX, particle.xPos,
particle.yPos, particle.yPos,
particle.width, particle.width,
particle.height, particle.height,
particle.texture, particle.texture,
1, particle.opacity,
0 0
); );
-- game.Log(particle.currentX, game.LOGGER_ERROR) -- game.Log(particle.currentX, game.LOGGER_ERROR)