2022-03-09 11:04:28 +01:00
|
|
|
local gen = {}
|
|
|
|
|
|
|
|
function gen:new(game,time,func,args)
|
|
|
|
|
|
|
|
local Transition = game.objects.base:new(game,0,0)
|
|
|
|
|
|
|
|
Transition.color = {0.161,0.157,0.192,1}
|
|
|
|
Transition.func = func
|
|
|
|
Transition.args = args
|
|
|
|
|
|
|
|
Transition.timer = game:Timer(time or 0.7)
|
|
|
|
|
|
|
|
Transition.depth = 99
|
|
|
|
|
|
|
|
function Transition:step(dt)
|
|
|
|
if self.timer:tick(dt) then
|
2022-03-10 10:47:12 +01:00
|
|
|
if self.timer.loops == 1 then
|
|
|
|
if self.func then
|
|
|
|
self.game.scenes[func](self.game.scenes,self.game,self.args)
|
|
|
|
local t = self.game.objects.transition:new(self.game,self.timer.maxcount)
|
|
|
|
self.game:summon(t)
|
|
|
|
end
|
2022-03-09 11:04:28 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Transition:draw()
|
2022-03-10 10:47:12 +01:00
|
|
|
if self.timer.loops<1 then
|
|
|
|
local offset = self.game.HEIGHT
|
|
|
|
if not self.func then offset = 0 end
|
|
|
|
lg.setColor(self.color)
|
|
|
|
lg.rectangle("fill",0,offset-self.game.HEIGHT*(1-self.timer:getratio()), self.game.WIDTH,self.game.HEIGHT)
|
|
|
|
lg.setColor({1,1,1,1})
|
|
|
|
end
|
2022-03-09 11:04:28 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return Transition
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return gen
|