player disappear after switching gamestate
Posted: Fri May 03, 2013 8:22 pm
Hi everyone,
I'm new and got a little problem here.
Here is my code so far. If you run it you can switch to the titlescreen with escape and go back to the game with return. After you've switched from the gamescreen to the titlescreen and then back to the gamescreen the player disappeared and I have no clue why. Maybe there is a problem with the setState function but I can't find it.
Maybe one of you could help.
Maybe relevant snippets:
Thanks in advance!
I'm new and got a little problem here.
Here is my code so far. If you run it you can switch to the titlescreen with escape and go back to the game with return. After you've switched from the gamescreen to the titlescreen and then back to the gamescreen the player disappeared and I have no clue why. Maybe there is a problem with the setState function but I can't find it.
Maybe one of you could help.
Maybe relevant snippets:
Code: Select all
-- Main
require("src.state")
require("src.world")
require("src.entity")
local State
function setState( newState )
if State ~= nil then State:leave() end
State = newState
State:init()
end
Code: Select all
function gamescreen:init()
World = world.new()
player = entity.new( 100, 100 )
World:add( player )
require("src.player")
end
function gamescreen:update(dt)
World:update(dt)
end
function gamescreen:draw()
World:draw()
love.graphics.setColor( 255, 255, 255 )
love.graphics.print( "FPS: "..love.timer.getFPS(), 10, 10 )
end