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
|
||||
|
||||
function CoreSystem:new(DEBUGMODE)
|
||||
self.modules = modules
|
||||
|
||||
self.debug = DebugSystem(self, DEBUGMODE)
|
||||
self.options = Options(self)
|
||||
self.input = Input(self)
|
||||
self.screen = Screen(self)
|
||||
self.scenemanager = SceneManager(self)
|
||||
self.lang = Lang(self)
|
||||
|
||||
self.modules = modules
|
||||
end
|
||||
|
||||
function CoreSystem:registerGameSystem(gamesystem)
|
||||
|
@ -94,6 +94,7 @@ end
|
|||
function CoreSystem:update(dt)
|
||||
self.debug:update(dt)
|
||||
self.input:update(dt)
|
||||
self.screen:update(dt)
|
||||
|
||||
if (self.game ~= nil) then
|
||||
self.game:update(dt)
|
||||
|
@ -107,6 +108,7 @@ end
|
|||
|
||||
function CoreSystem:draw()
|
||||
self.scenemanager:draw()
|
||||
self.screen:drawFade()
|
||||
end
|
||||
|
||||
-- EXIT FUNCTIONS
|
||||
|
|
|
@ -39,6 +39,10 @@ function ScreenManager:new(controller)
|
|||
CScreen.setColor(0, 0, 0, 1)
|
||||
|
||||
love.graphics.setDefaultFilter( "nearest", "nearest", 1 )
|
||||
|
||||
self.timers = self.controller.modules.Timers(self)
|
||||
|
||||
self.transitionValue = 0
|
||||
end
|
||||
|
||||
function ScreenManager:applySettings()
|
||||
|
@ -93,6 +97,34 @@ function ScreenManager:resetScissor()
|
|||
love.graphics.setScissor( )
|
||||
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
|
||||
-- Apply draw functions to the scene
|
||||
|
|
Loading…
Reference in a new issue