feat(screen): add screen transitions
This commit is contained in:
parent
a1afa0821c
commit
8385a69636
2 changed files with 36 additions and 2 deletions
|
@ -49,14 +49,14 @@ require(cwd .. "callbacks")
|
||||||
-- Initialize and configure the core object
|
-- Initialize and configure the core object
|
||||||
|
|
||||||
function CoreSystem:new(DEBUGMODE)
|
function CoreSystem:new(DEBUGMODE)
|
||||||
|
self.modules = modules
|
||||||
|
|
||||||
self.debug = DebugSystem(self, DEBUGMODE)
|
self.debug = DebugSystem(self, DEBUGMODE)
|
||||||
self.options = Options(self)
|
self.options = Options(self)
|
||||||
self.input = Input(self)
|
self.input = Input(self)
|
||||||
self.screen = Screen(self)
|
self.screen = Screen(self)
|
||||||
self.scenemanager = SceneManager(self)
|
self.scenemanager = SceneManager(self)
|
||||||
self.lang = Lang(self)
|
self.lang = Lang(self)
|
||||||
|
|
||||||
self.modules = modules
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function CoreSystem:registerGameSystem(gamesystem)
|
function CoreSystem:registerGameSystem(gamesystem)
|
||||||
|
@ -94,6 +94,7 @@ end
|
||||||
function CoreSystem:update(dt)
|
function CoreSystem:update(dt)
|
||||||
self.debug:update(dt)
|
self.debug:update(dt)
|
||||||
self.input:update(dt)
|
self.input:update(dt)
|
||||||
|
self.screen:update(dt)
|
||||||
|
|
||||||
if (self.game ~= nil) then
|
if (self.game ~= nil) then
|
||||||
self.game:update(dt)
|
self.game:update(dt)
|
||||||
|
@ -107,6 +108,7 @@ end
|
||||||
|
|
||||||
function CoreSystem:draw()
|
function CoreSystem:draw()
|
||||||
self.scenemanager:draw()
|
self.scenemanager:draw()
|
||||||
|
self.screen:drawFade()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- EXIT FUNCTIONS
|
-- EXIT FUNCTIONS
|
||||||
|
|
|
@ -39,6 +39,10 @@ function ScreenManager:new(controller)
|
||||||
CScreen.setColor(0, 0, 0, 1)
|
CScreen.setColor(0, 0, 0, 1)
|
||||||
|
|
||||||
love.graphics.setDefaultFilter( "nearest", "nearest", 1 )
|
love.graphics.setDefaultFilter( "nearest", "nearest", 1 )
|
||||||
|
|
||||||
|
self.timers = self.controller.modules.Timers(self)
|
||||||
|
|
||||||
|
self.transitionValue = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
function ScreenManager:applySettings()
|
function ScreenManager:applySettings()
|
||||||
|
@ -93,6 +97,34 @@ function ScreenManager:resetScissor()
|
||||||
love.graphics.setScissor( )
|
love.graphics.setScissor( )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- UPDATE FUNCTIONS
|
||||||
|
-- Update the screen
|
||||||
|
|
||||||
|
function ScreenManager:update(dt)
|
||||||
|
self.timers:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TRANSITION FUNCTIONS
|
||||||
|
-- Handle transitions
|
||||||
|
|
||||||
|
function ScreenManager:fadeIn(duration, easing)
|
||||||
|
local duration = duration or 1
|
||||||
|
local easing = easing or "inExpo"
|
||||||
|
self.timers:newTween(0, duration, {transitionValue = 1}, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScreenManager:fadeOut(duration, easing)
|
||||||
|
local duration = duration or 1
|
||||||
|
local easing = easing or "outExpo"
|
||||||
|
self.timers:newTween(0, duration, {transitionValue = 0}, easing)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ScreenManager:drawFade()
|
||||||
|
local w, h = self:getDimensions()
|
||||||
|
love.graphics.setColor(0, 0, 0, self.transitionValue)
|
||||||
|
love.graphics.rectangle("fill", 0, 0, w, h)
|
||||||
|
utils.graphics.resetColor()
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Apply draw functions to the scene
|
-- Apply draw functions to the scene
|
||||||
|
|
Loading…
Reference in a new issue