Trying to implement a menu system/pause screen

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
sp00kymuld3r
Prole
Posts: 2
Joined: Tue Oct 30, 2018 2:33 pm

Trying to implement a menu system/pause screen

Post 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 3943 times
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Trying to implement a menu system/pause screen

Post by veethree »

I'm guessing enemy.img doesn't exists or isn't an image that has a "getWidth" method.
User avatar
sp00kymuld3r
Prole
Posts: 2
Joined: Tue Oct 30, 2018 2:33 pm

Re: Trying to implement a menu system/pause screen

Post 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...
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Trying to implement a menu system/pause screen

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 7 guests