I have a little bit of a problem that may just turn out to be a simple misunderstanding. I am trying to create a game with a gravity function. The gravity function looks at a boolean called "stopGravity" to see if the gravity should be stopped, this boolean is located in the parent class and it is protected. However, when returning "stopGravity"'s value it returns as false (which is correct) on two classes, but the third class always returns true.
The only place where the "stopGravity" boolean is changed is in one of the three classes returning it's value, there is only one function that can change it. I have put breakpoints to see if the functions are working correctly and they are.
So I am starting to think that this boolean in the parent class is not unique, that is, it has separate values for each class that accesses it. If this is the case I will just have to create some more functions which change "stopGravity" for each class returning it's value.
I always thought that any variable in the parent class was unique to that class and it's value would always stay the same even if separate classes are returning it's value, but I'm probably wrong (it has been a while since I did any programming).
A class' internal variables are unique to every instance of the class, unless you've done things to make it otherwise.
If your base class has a variable, and then you make three separate instances of a derived class, each of those derived class has its own personal set of variables, including the variables it inherited.