Hello,
I'm getting this error in the following code in line 18:
-- Vector2 class: a two dimensional Vector
Vector2 = Core.class()
function Vector2:init()
self.x = 0
self.y = 0
end
function Vector2:create(x,y)
newvec = Vector2.new()
newvec.x = x
newvec.y = y
return newvec
end
function Vector2:toString()
return tostring(self.x)..tostring(self.y) -- << this is where the error occurs
end
myVector = Vector2:create(2,4)
print(myVector.toString())
So, I guess the question is, how do I operate with an objects own properties inside a function that belongs to that object.
Thanks,
David
Comments
When you are calling the same in
all you need to do is either
1.
2.
Likes: ar2rsawseen, dddent
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps