NeutronLoved/objects/transition.lua

42 lines
968 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.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
end
end
end
function Transition:draw()
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
end
return Transition
end
return gen