Page 1 of 1

Trying to implement a menu system/pause screen

Posted: Tue Oct 30, 2018 2:48 pm
by sp00kymuld3r
Hi everyone,

I've been learning Lua/Love for the past few weeks but I've hit an impasse. I have a prototype of a simple game that works almost how I want, but I'm now trying to implement a menu system as well as a few other things but I'm going round in circles. I get this error:
Error

main.lua:139: attempt to call method 'getWidth' (a nil value)


Traceback

main.lua:139: in function 'update'
[C]: in function 'xpcall'
which is referring to this section of code:
The attachment lovescreen.png is no longer available
I know I need to change something to do with getWidth but I can't see what. I've also attached a .love file to this post in the hope that someone can delve into it and help me out.

Thanks guys!
lovescreen.png
lovescreen.png (39.71 KiB) Viewed 3944 times

Re: Trying to implement a menu system/pause screen

Posted: Tue Oct 30, 2018 6:59 pm
by veethree
I'm guessing enemy.img doesn't exists or isn't an image that has a "getWidth" method.

Re: Trying to implement a menu system/pause screen

Posted: Wed Oct 31, 2018 1:15 pm
by sp00kymuld3r
Thanks! After some poking around I managed to get it to work. Now I just need to figure out how to pause the game, have a box appear with a question pulled from the database and have 'True' and 'False' buttons...

Re: Trying to implement a menu system/pause screen

Posted: Thu Nov 01, 2018 10:30 pm
by veethree

Code: Select all

paused = false

if paused then
  --All the game updating shit goes here
end
Then use the same paused boolean to determine if the box should appear. There's plenty of GUI libraries available for buttons and such. Or you can make your own.