Pygame, Self Is Not Defined
So I'm getting this error when I compile, I don't understand though because I've got 2 identical classes, one works fine the other throws out this error. if self.currentState2==1:
Solution 1:
Your indentation is incorrect in the method calculateNextPosition
. As a result, the series of if statements are executed in the body of the class (not the method), where self
isn't defined.
Solution 2:
You need to indent these lines:
if self.currentState2==1:
elif self.currentState2==0:
They are not considered part of the function def since they have the same indentation as the function name.
Solution 3:
Your indentation is off. The if statement is outside of the method you think it's in.
Solution 4:
Check your indentation - the condition is on the same level as your function definition. In other words it's not inside the function so technically yes - self is not defined.
Post a Comment for "Pygame, Self Is Not Defined"