[SOLVED] Hump.gamestate - switch inside update problem
Posted: Sat Sep 17, 2016 10:14 am
Hi. I noticed that when I call Gamestate.switch(nextGamestate) from another gamestate's update(dt), the screen blinks as if empty background is drawn for a single frame. If I call switch from somewhere else like keypressed, there is no problem. Can you please help me to get rid of this annoying blinking?
Here is example code:
Here is example code:
Code: Select all
Gamestate = require('lib.hump.gamestate')
local state1 = {}
local state2 = {}
local time = 0
function love.load()
love.graphics.setBackgroundColor(0,255,0)
Gamestate.registerEvents()
Gamestate.switch(state1)
end
function state1:update(dt)
time = time + dt
if time > 3 then
time = 0
Gamestate.switch(state2)
end
end
function state1:draw()
love.graphics.setColor(255,0,0)
love.graphics.rectangle('fill',0,0,2000,2000)
end
function state2:draw()
love.graphics.setColor(255,0,0)
love.graphics.rectangle('fill',0,0,2000,2000)
end
function state2:keypressed()
Gamestate.switch(state1)
end