Allow arbitraty gamestate callbacks

This commit is contained in:
Matthias Richter 2013-01-26 12:56:59 +01:00
parent bf862c9b40
commit d22749990d

View File

@ -32,21 +32,7 @@ local current = setmetatable({leave = __NULL__}, {__index = __ERROR__})
local GS = {}
function GS.new()
return {
init = __NULL__,
enter = __NULL__,
leave = __NULL__,
update = __NULL__,
draw = __NULL__,
focus = __NULL__,
keyreleased = __NULL__,
keypressed = __NULL__,
mousepressed = __NULL__,
mousereleased = __NULL__,
joystickpressed = __NULL__,
joystickreleased = __NULL__,
quit = __NULL__,
}
return setmetatable({}, {__index = function() return __NULL__ end})
end
function GS.switch(to, ...)
@ -54,7 +40,7 @@ function GS.switch(to, ...)
current:leave()
local pre = current
to:init()
to.init = __NULL__
to.init = nil
current = to
return current:enter(pre, ...)
end