Having more than one image on the screen
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Having more than one image on the screen
For some odd reason, I am having trouble displaying more than one image on the screen. Attached is the .love file of my project. Does anyone know what is wrong? Why does it only display one image, and not both?
- Attachments
-
- LoveProject.love.zip
- The buggy code
- (5.96 KiB) Downloaded 104 times
Re: Having more than one image on the screen
You're using global variables instead of the values from the Rock instance.
This will return the value of the global variable x.
You probably want to use self.x here to get the x from the Rock instance.
There are a few more places where self is missing.
Code: Select all
function Rock:getX()
return x
end
You probably want to use self.x here to get the x from the Rock instance.
Code: Select all
function Rock:getX()
return self.x
end
Shallow indentations.
Re: Having more than one image on the screen
Oh... Thanks. I'm new to lua, so I don't quite have the whole global/local thing figured out yet.
Re: Having more than one image on the screen
Local is just to the function. If I have a function with a local variable, I can reuse that variable later, out of the function.
A global can be used ANYWHERE.
Code: Select all
function code()
local localCode={"This is a table with a string"}
end
print(localCode[1]) --Results in error.
Code: Select all
function code()
return {"This may or may not be a variable when this is called"}
end
globalCode=code()
print(globalCode[1]) --Prints "This may or may not be a variable when this is called"
"your actions cause me to infer your ego is the size of three houses" -finley
Re: Having more than one image on the screen
Thanks. I've figured out how the local/global stuff works now though.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 9 guests