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?
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
Last edited by bloodcraft on Sat Sep 17, 2016 12:33 pm, edited 1 time in total.
You din't see a flash of green color after 3 seconds? That's weird. I just tried to run it on a different computer and made sure I have most recent versions of löve and hump but it didn't help.
It's the one thing I hate about hump.gamestate. After switching, no events are forwarded until the next update[source]. You can patch it out, or delay switching. If you do patch it out, you will run into situations where draw will run before update, but if your state is well-designed, that shouldn't be a problem.
Mind you all, this behaviour didn't exist previously, but was patched in after an issue was raised, wherein vrld deemed it the correct course of action.
My solution was to use an older version that did not include this fix.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.