+ after scroll animation timing and some effects that use it

This commit is contained in:
FajsiEx 2021-07-31 22:14:34 +02:00
parent 8ffc12f82a
commit c2619a2af0
1 changed files with 47 additions and 4 deletions

View File

@ -77,6 +77,11 @@ local transitionScrollScale = 0;
local transitionScrollOffsetY = 0;
local scrollingUp = false;
local transitionAfterscrollScale = 0;
local transitionAfterscrollDataOverlayAlpha = 0;
local transitionAfterscrollGradeAlpha = 0;
local transitionAfterscrollBadgeAlpha = 0;
function resetLayoutInformation()
resx, resy = game.GetResolution()
desw = 1080
@ -163,7 +168,7 @@ function drawBackground()
local bestScore = diff.scores[1];
if song and diff and bestScore then
gfx.BeginPath()
gfx.ImageRect(0, 0, desw, desh, dataBackgroundOverlayImage, 1, 0)
gfx.ImageRect(0, 0, desw, desh, dataBackgroundOverlayImage, transitionAfterscrollDataOverlayAlpha, 0)
end
end
@ -264,6 +269,7 @@ function drawData() -- Draws the song data on the left panel
gfx.BeginPath()
gfx.ImageRect(96, 324, 348, 348, jacketImage or defaultJacketImage, 1, 0)
gfx.Save()
if bestScore then
-- Draw best score
gfx.BeginPath()
@ -277,15 +283,17 @@ function drawData() -- Draws the song data on the left panel
end
gfx.BeginPath();
gfx.ImageRect(360, 773, 45, 45, gradeImage, 1, 0);
gfx.ImageRect(360, 773, 45, 45, gradeImage, transitionAfterscrollGradeAlpha, 0);
-- Draw badge
badgeImage = badgeImages[bestScore.badge+1];
gfx.BeginPath()
gfx.ImageRect(425, 724, 93/1.1, 81/1.1, badgeImage, 1, 0)
gfx.ImageRect(425, 724, 93/1.1, 81/1.1, badgeImage, transitionAfterscrollBadgeAlpha, 0)
end
gfx.Restore()
-- Draw BPM
gfx.BeginPath();
gfx.FontSize(24)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
gfx.Save()
@ -308,11 +316,45 @@ function tickTransitions(deltaTime)
transitionScrollScale = 1
end
if transitionAfterscrollScale < 1 then
if transitionScrollScale == 1 then
-- Only start the after scroll transition when the scroll transition is finished
transitionAfterscrollScale = transitionAfterscrollScale + deltaTime / 0.5
end
else
transitionAfterscrollScale = 1;
end
if scrollingUp then
transitionScrollOffsetY = Easing.inQuad(1-transitionScrollScale) * songPlateHeight;
else
transitionScrollOffsetY = Easing.inQuad(1-transitionScrollScale) * -songPlateHeight;
end
if transitionAfterscrollScale < 0.5 then
transitionAfterscrollDataOverlayAlpha = math.min(1, transitionAfterscrollScale / 0.5)
else
transitionAfterscrollDataOverlayAlpha = 1;
end
-- Grade alpha
if transitionAfterscrollScale >= 0.7 and transitionAfterscrollScale < 0.8 then
transitionAfterscrollGradeAlpha = 0.5;
elseif transitionAfterscrollScale >= 0.95 then
transitionAfterscrollGradeAlpha = 1;
else
transitionAfterscrollGradeAlpha = 0;
end
-- Badge alpha
if transitionAfterscrollScale >= 0.75 and transitionAfterscrollScale < 0.85 then
transitionAfterscrollBadgeAlpha = 0.5;
elseif transitionAfterscrollScale >= 1 then
transitionAfterscrollBadgeAlpha = 1;
else
transitionAfterscrollBadgeAlpha = 0;
end
end
@ -338,11 +380,12 @@ render = function (deltaTime)
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_TOP)
local debugScrollingUp= "FALSE"
if scrollingUp then debugScrollingUp = "TRUE" end;
gfx.Text('DELTA: ' .. deltaTime .. ' // SELECTED_INDEX: ' .. selectedIndex .. ' // SELECTED_DIFF: ' .. selectedDifficulty .. ' // SCROLLING_UP: ' .. debugScrollingUp, 8, 8);
gfx.Text('DELTA: ' .. deltaTime .. ' // SELECTED_INDEX: ' .. selectedIndex .. ' // SELECTED_DIFF: ' .. selectedDifficulty .. ' // SCROLLING_UP: ' .. debugScrollingUp .. ' // AC_TS: ' .. transitionAfterscrollScale, 8, 8);
end
set_index = function(newIndex)
transitionScrollScale = 0;
transitionAfterscrollScale = 0;
scrollingUp = false;
if ((newIndex > selectedIndex and not (newIndex == #songwheel.songs and selectedIndex == 1)) or (newIndex == 1 and selectedIndex == #songwheel.songs)) then