+ scaling suport to songtransition screen & + fade in and fade out animations to songtransition screen

This commit is contained in:
FajsiEx 2021-07-27 19:41:26 +02:00
parent eee4922e18
commit c23b407e53
1 changed files with 53 additions and 13 deletions

View File

@ -12,29 +12,69 @@ local difficultyLabelImages = {
gfx.CreateSkinImage("songtransition/difficulty_labels/mxm.png", 0),
}
local transitionTimer = 3
local transitionTimer = 0;
local outTimer = 0
local resx, resy = game.GetResolution()
local outTimer = 1
local desw, desh -- The resolution of the deisign
local scale;
local noJacket = gfx.CreateSkinImage("song_select/loading.png", 0)
local wasEnterSfxPlayed = false;
function resetLayoutInformation()
resx, resy = game.GetResolution()
-- portrait = resy > resx
-- desw = portrait and 1080 or 1920
-- desh = desw * (resy / resx)
desw = 1080
desh = 1920
scale = resx / desw
end
function render(deltaTime)
if not wasEnterSfxPlayed then
game.PlaySample('song_transition_screen/transition_enter.wav');
wasEnterSfxPlayed = true;
end
render_screen(transitionTimer)
transitionTimer = transitionTimer + deltaTime * 2
resetLayoutInformation()
gfx.ResetTransform();
gfx.Scale(scale, scale);
render_screen(transitionTimer);
transitionTimer = transitionTimer + deltaTime * 0.2
transitionTimer = math.min(transitionTimer,1)
if transitionTimer < 0.25 then
local whiteAlpha = math.max(0, (1-transitionTimer/0.25))
gfx.BeginPath();
gfx.FillColor(255,255,255,math.floor(255*whiteAlpha));
gfx.Rect(0,0,desw,desh);
gfx.Fill();
gfx.ClosePath();
end
if transitionTimer > 0.85 then
local blackAlpha = math.min(1, ((transitionTimer-0.85)/0.15))
gfx.BeginPath();
gfx.FillColor(0,0,0,math.floor(255*blackAlpha));
gfx.Rect(0,0,desw,desh);
gfx.Fill();
gfx.ClosePath();
end
return transitionTimer >= 1
end
function render_out(deltaTime)
outTimer = outTimer + deltaTime * 2
outTimer = math.min(outTimer, 2)
-- render_screen(outTimer)
outTimer = outTimer + deltaTime * 0.2
outTimer = math.min(outTimer, 1)
return outTimer >= 1;
end
@ -43,7 +83,7 @@ function sign(x)
end
function render_screen(progress)
gfx.ImageRect(0, 0, resx, resy, bgImage,1,0);
gfx.ImageRect(0, 0, 1080, 1920, bgImage,1,0);
local jacket = song.jacket == 0 and noJacket or song.jacket
@ -56,10 +96,10 @@ function render_screen(progress)
gfx.TextAlign(gfx.TEXT_ALIGN_CENTER + gfx.TEXT_ALIGN_MIDDLE)
gfx.FontSize(55)
gfx.Text(song.title,resx/2, 1114)
gfx.Text(song.title,desw/2, 1114)
gfx.FontSize(30)
gfx.Text(song.artist, resx/2 , 1182)
gfx.Text(song.artist, desw/2 , 1182)
local EFFECTOR_LABEL_Y = 1288
@ -67,8 +107,8 @@ function render_screen(progress)
gfx.FontSize(22)
gfx.Text(song.effector, resx/2+70 , EFFECTOR_LABEL_Y-1)
gfx.Text(song.illustrator, resx/2+70 , ILLUSTRATOR_LABEL_Y-3)
gfx.Text(song.effector, desw/2+70 , EFFECTOR_LABEL_Y-1)
gfx.Text(song.illustrator, desw/2+70 , ILLUSTRATOR_LABEL_Y-3)
gfx.BeginPath();
local diffLabelImage = difficultyLabelImages[song.difficulty+1];
@ -116,6 +156,6 @@ end
function reset()
transitionTimer = 0
resx, resy = game.GetResolution()
outTimer = 1
outTimer = 0
wasEnterSfxPlayed = false;
end