but when i try to execute, i got this error “File “C:\Skykobe\ProjectA\data\stage0.py”, line 45, in Stage_cero
taskMgr.add(self._camFollowChar, “CameraFollowsChar”)
NameError: name ‘self’ is not defined”, evidently i dont know why system tells my that self is not defined if i have it in the parameter of the function.
You need to add that task to the task manager during the initialisation of the class instance. (Someone cleverer than me will have to explain why it doesn’t work where it is… I am a complete newbie to all this)
(You also need to add an instance of the class and run the game, but I suppose you are doing that in another module.)
Oh, and arguments to the “camFollowChar” method are in the wrong order. “self” always comes first.
In Digimikeh’s original code, the taskMgr.add is sitting in class attribute space. (Or whatever Python calls it.) Since this is before the class is instanced, there is no “self” to speak of as of yet. That’s why moving it to the constructor works.
Note that Python really plays loose and fast with the concept of object-oriented, so I’m mostly speaking from a C+±like manner. “Constructor” and “Attributes” are just conveniences.