I have a python file I’m trying to add to the BGE, it contains (more or less) the following:
class objectOne:
posX = 0
posY = 0
(constructor and some function defs follow)
class objectTwo:
(some params, constructor)
def rememberObject(object,location)
x = object.posX
y = object.posY
As you can see I’d like to pass an object of the class objectOne to the rememberObject method of objectTwo. However, when I try to do this, the line
x = object.posX
gives the following error:
AttributeError: ‘objectTwo’ object has no attribute ‘posX’
I’ve been trying for hours and searching everywhere but still can’t figure out how to do this properly.
Any hints in the right direction MUCH appreciated!
the first parameter of a member function is reserved for the object instance the function is called from. So the first parameter can’t be specified when you call that member function as it is implicitly set to the object.
Usually you call this parameter “self” so that you always know that this is gonna be the parameter you can use to access the object itself. But in fact you could call it anything you like (like in your case “object”).