feat: add transition system
This commit is contained in:
parent
b1e308bf82
commit
e08e689586
8 changed files with 99 additions and 2 deletions
|
@ -97,6 +97,7 @@ function CoreSystem:update(dt)
|
|||
end
|
||||
|
||||
self.scenemanager:update(dt)
|
||||
self.screen:update(dt)
|
||||
end
|
||||
|
||||
-- DRAW FUNCTIONS
|
||||
|
|
|
@ -72,7 +72,7 @@ function Scene:updateEnd(dt)
|
|||
end
|
||||
|
||||
function Scene:updateWorld(dt)
|
||||
if (self.world ~= nil) and (self.world.isActive) then
|
||||
if ((self.world ~= nil) and (self.world.isActive) and core.screen:isActive()) then
|
||||
self.world:update(dt)
|
||||
end
|
||||
end
|
||||
|
|
14
sonic-radiance.love/core/modules/transitions/default.lua
Normal file
14
sonic-radiance.love/core/modules/transitions/default.lua
Normal file
|
@ -0,0 +1,14 @@
|
|||
local TransitionParent = require "core.modules.transitions.parent"
|
||||
local DefaultTransition = TransitionParent:extend()
|
||||
|
||||
function DefaultTransition:new(func, ox, oy, fadeOut)
|
||||
DefaultTransition.super.new(self, func, ox, oy, fadeOut, "inQuad", "outQuad", 0.35, 0.15)
|
||||
end
|
||||
|
||||
function DefaultTransition:draw()
|
||||
love.graphics.setColor(0,0,0,self.value)
|
||||
love.graphics.rectangle("fill", 0, 0, 424, 240)
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
|
||||
return DefaultTransition
|
3
sonic-radiance.love/core/modules/transitions/init.lua
Normal file
3
sonic-radiance.love/core/modules/transitions/init.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
default = require "core.modules.transitions.default"
|
||||
}
|
43
sonic-radiance.love/core/modules/transitions/parent.lua
Normal file
43
sonic-radiance.love/core/modules/transitions/parent.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
local TransitionParent = Object:extend()
|
||||
local TweenManager = require "game.modules.tweenmanager"
|
||||
|
||||
function TransitionParent:new(func, ox, oy, fadeOut, easeIn, easeOut, duration, wait)
|
||||
print(func, ox, oy, fadeOut, easeIn, easeOut, duration)
|
||||
self.tween = TweenManager(self)
|
||||
self:loadResources()
|
||||
self.func = func
|
||||
self.ox = ox or 0
|
||||
self.oy = oy or 0
|
||||
self.fadeOut = fadeOut
|
||||
if (self.fadeOut) then
|
||||
self.value = 1
|
||||
self.tween:newTween(wait, duration, {value = 0}, easeOut)
|
||||
else
|
||||
self.value = 0
|
||||
self.tween:newTween(0, duration, {value = 1}, easeIn)
|
||||
end
|
||||
self.tween:newTimer(duration + wait, "isOver")
|
||||
end
|
||||
|
||||
function TransitionParent:loadResources()
|
||||
--vide par defaut
|
||||
end
|
||||
|
||||
function TransitionParent:update(dt)
|
||||
self.tween:update(dt)
|
||||
end
|
||||
|
||||
function TransitionParent:timerResponse(timer)
|
||||
if (timer == "isOver") then
|
||||
if (self.func ~= nil) then
|
||||
self.func()
|
||||
end
|
||||
core.screen:transitionOver(self.fadeOut)
|
||||
end
|
||||
end
|
||||
|
||||
function TransitionParent:draw()
|
||||
|
||||
end
|
||||
|
||||
return TransitionParent
|
|
@ -130,6 +130,7 @@ function SceneManager:draw()
|
|||
self.currentScene:draw()
|
||||
self.currentScene.menusystem:draw()
|
||||
self.currentScene:drawEnd()
|
||||
self.controller.screen:drawTransition()
|
||||
end
|
||||
self.controller.screen:cease()
|
||||
end
|
||||
|
|
|
@ -39,6 +39,27 @@ function ScreenManager:new(controller)
|
|||
CScreen.setColor(0, 0, 0, 1)
|
||||
|
||||
love.graphics.setDefaultFilter( "nearest", "nearest", 1 )
|
||||
|
||||
self.transition = nil
|
||||
self.transitionOut = nil
|
||||
self.isOpaque = false
|
||||
end
|
||||
|
||||
function ScreenManager:startTransition(transitionIn, transitionOut, func, x, y)
|
||||
self.transition = transitionIn(func, x, y, false)
|
||||
self.transitionOut = transitionOut(nil, x, y, true)
|
||||
end
|
||||
|
||||
function ScreenManager:transitionOver(fadeOut)
|
||||
if (not fadeOut) then
|
||||
self.transition = self.transitionOut
|
||||
else
|
||||
self.transition = nil
|
||||
end
|
||||
end
|
||||
|
||||
function ScreenManager:isActive()
|
||||
return ((self.transition == nil) and (not self.isOpaque))
|
||||
end
|
||||
|
||||
function ScreenManager:applySettings()
|
||||
|
@ -55,6 +76,12 @@ function ScreenManager:applySettings()
|
|||
CScreen.update(width, height)
|
||||
end
|
||||
|
||||
function ScreenManager:update(dt)
|
||||
if (self.transition ~= nil) then
|
||||
self.transition:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
-- POINTER FUNCTIONS
|
||||
-- Translate the pointer according to the screen coordinates
|
||||
|
||||
|
@ -104,4 +131,10 @@ function ScreenManager:cease()
|
|||
CScreen.cease()
|
||||
end
|
||||
|
||||
function ScreenManager:drawTransition()
|
||||
if (self.transition ~= nil) then
|
||||
self.transition:draw()
|
||||
end
|
||||
end
|
||||
|
||||
return ScreenManager
|
||||
|
|
|
@ -21,7 +21,9 @@ function Charset:new(scene)
|
|||
end
|
||||
|
||||
function Charset:update(dt)
|
||||
if (core.screen:isActive()) then
|
||||
self.currentFrame = ((self.currentFrame + (dt*5)) % 4)
|
||||
end
|
||||
end
|
||||
|
||||
function Charset:addChar(ii, jj)
|
||||
|
|
Loading…
Reference in a new issue