feat: add transitions between title and menu

This commit is contained in:
Kazhnuz 2021-04-05 12:29:45 +02:00
parent f59ebd11e5
commit f538ffa94a
4 changed files with 38 additions and 15 deletions

View file

@ -16,7 +16,7 @@ function DebugMenu:new()
menu.commons.SceneWidget(self, "BaseMenu", scenes.overworld, "Start playing")
menu.commons.SceneWidget(self, "BaseMenu", scenes.options, "Options")
self:buildDebugMenu()
menu.commons.SceneWidget(self, "BaseMenu", scenes.title, "Return to title")
menu.TitleWidget(self, "BaseMenu")
menu.ExitWidget(self, "BaseMenu")
self.menusystem.menus["BaseMenu"]:finalize()

View file

@ -1,6 +1,9 @@
local commons = require "scenes.debug.commons.menu"
local listMenu = require "game.modules.menus.fancy"
local defTransitions = require "core.modules.transitions"
local radTransitions = require "game.modules.transitions"
local menu = {}
menu.commons = commons
menu.ExitWidget = listMenu.BaseWidget:extend()
@ -10,6 +13,16 @@ menu.LevelUpWidget = listMenu.BaseWidget:extend()
menu.AddRemoveWidget = listMenu.BaseWidget:extend()
menu.ChangeLeaderWidget = listMenu.BaseWidget:extend()
menu.ItemWidget = listMenu.BaseWidget:extend()
menu.TitleWidget = listMenu.BaseWidget:extend()
-- TitleWidget
function menu.TitleWidget:new(scene, menuName)
menu.TitleWidget.super.new(self, scene, menuName, "Return to Title", "")
end
function menu.TitleWidget:action()
core.screen:startTransition(defTransitions.circle, radTransitions.borders, function() scenes.title(true) end, 424/2, 240/2)
end
-- ExitWidget
function menu.ExitWidget:new(scene, menuName)

View file

@ -31,9 +31,11 @@ local Menu = require "scenes.menus.titlescreen.menu"
local zoneList = require("datas.gamedata.maps.shoot.zones")
function TitleScreen:new()
function TitleScreen:new(fromMenu)
TitleScreen.super.new(self)
local fromMenu = (fromMenu == true)
self.borders = gui.newBorder(424, 30, 8)
self.assets:addImage("logo", "assets/artworks/logo.png")
self.assets:addImageFont("menu", "assets/gui/fonts/SA2font")
@ -45,23 +47,29 @@ function TitleScreen:new()
self.tweens = TweenManager(self)
self:initBackground()
self.borderY = 0
self.logoX = 270
self.darkenOpacity = 1
self.haveMenu = false
self.flashOpacity = 0
self.canShowPressStart = false
self.showPressStart = true
self.showPressStartTimer = 0.5
self.haveMenu = false
if (fromMenu) then
self.darkenOpacity = 0
self.canShowPressStart = true
self.borderY = 30
self.logoX = 0
else
self.darkenOpacity = 1
self.canShowPressStart = false
self.borderY = 0
self.logoX = 270
self.tweens:newTween(0.2, 0.5, {borderY = 30}, "inOutQuart")
self.tweens:newTween(0.5, 0.4, {darkenOpacity = 0}, "outExpo")
self.tweens:newTween(0.7, 0.6, {logoX = 0}, "inOutQuart")
self.tweens:newTween(1.3, 0.03, {flashOpacity = 1}, "inQuart")
self.tweens:newTween(1.45, 0.2, {flashOpacity = 0}, "outExpo")
self.tweens:newSwitch(1.4, { "canShowPressStart" })
self.tweens:newTween(0.2, 0.5, {borderY = 30}, "inOutQuart")
self.tweens:newTween(0.5, 0.4, {darkenOpacity = 0}, "outExpo")
self.tweens:newTween(0.7, 0.6, {logoX = 0}, "inOutQuart")
self.tweens:newTween(1.3, 0.03, {flashOpacity = 1}, "inQuart")
self.tweens:newTween(1.45, 0.2, {flashOpacity = 0}, "outExpo")
self.tweens:newSwitch(1.4, { "canShowPressStart" })
end
end
function TitleScreen:initBackground()

View file

@ -6,6 +6,8 @@ local SaveWidget = RadianceWidget:extend()
local gui = require "game.modules.gui"
local charutils = require "game.utils.characters"
local defTransitions = require "core.modules.transitions"
local radTransitions = require "game.modules.transitions"
local HPADDING = 68
local VPADDING = 28
@ -60,7 +62,7 @@ end
function SaveWidget:action()
game:read(self.saveid)
scenes.debug.menu()
core.screen:startTransition(radTransitions.borders, defTransitions.circle, function() scenes.debug.menu() end, 424/2, 240/2)
end
return SaveMenu