"stateswitcher" and Images
Posted: Wed Oct 02, 2019 7:04 pm
Hello, I'm new to Löve2D and LUA in general. My goal is to create a simple menu with a background, so I installed "stateswitcher" (https://love2d.org/wiki/Stateswitcher).
In my "menu.lua" I tried to load this image and draw it, but it won't work:
My main.lua:
My "menu.lua":
If I use the menu.lua code in my "main.lua" without stateswitcher it works like a charm.
What am I doing wrong?
Thanks!
In my "menu.lua" I tried to load this image and draw it, but it won't work:
Code: Select all
Error
menu.lua:16: bad argument #1 to 'draw' (Drawable expected, got nil)
Traceback
[C]: in function 'draw'
menu.lua:16: in function 'draw'
[C]: in function 'xpcall'
My main.lua:
Code: Select all
state=require("lib.state.stateswitcher")
function love.load()
state.switch("menu")
end
My "menu.lua":
Code: Select all
state=require("lib.state.stateswitcher")
anim = require('lib.anim8.anim8')
function love.load()
bgimg = love.graphics.newImage("img/bg.png")
end
function love.update(dt)
end
function love.draw()
love.graphics.draw(bgimg)
end
If I use the menu.lua code in my "main.lua" without stateswitcher it works like a charm.
What am I doing wrong?
Thanks!