39 lines
920 B
Lua
39 lines
920 B
Lua
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
|
|
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
|
|
self.game:delid(self.id)
|
|
end
|
|
end
|
|
|
|
function Transition:draw()
|
|
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
|
|
|
|
return Transition
|
|
|
|
end
|
|
|
|
return gen
|