mirror of
https://github.com/vrld/hump.git
synced 2024-11-23 12:24:19 +00:00
Bug: prevent from switching to initial gamestate
This commit is contained in:
parent
5030f4db60
commit
6315155955
@ -1,10 +1,11 @@
|
||||
Gamestate = {}
|
||||
|
||||
local function __NULL__() end
|
||||
-- default gamestate produces error on every callback
|
||||
local function __ERROR__() error("Gamestate not initialized. Use Gamestate.switch()") end
|
||||
Gamestate.current = {
|
||||
enter = __ERROR__,
|
||||
leave = __ERROR__,
|
||||
leave = __NULL__,
|
||||
update = __ERROR__,
|
||||
draw = __ERROR__,
|
||||
keyreleased = __ERROR__,
|
||||
@ -12,7 +13,6 @@ Gamestate.current = {
|
||||
mousereleased = __ERROR__,
|
||||
}
|
||||
|
||||
local function __NULL__() end
|
||||
function Gamestate.new()
|
||||
return {
|
||||
enter = __NULL__,
|
||||
@ -27,9 +27,7 @@ end
|
||||
|
||||
function Gamestate.switch(to, ...)
|
||||
if not to then return end
|
||||
if Gamestate.current then
|
||||
Gamestate.current:leave()
|
||||
end
|
||||
local pre = Gamestate.current
|
||||
Gamestate.current = to
|
||||
Gamestate.current:enter(pre, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user