Search code examples
cobjective-ccocoa-touchchipmunk

What's happening to the value of my member?


There's a joke in there somewhere.

Anyhoot. In the following code, the setForceVector method has no actual effect on the value of member it's attempting to change. By checking the log, I can see the function is being called (by another object handling to a touchEvent).

I've used NSLog to check that the forceVectorfromControls is actually coming across as expected and it is.

If I set the value of forceVector in the init or step methods it works as intended. But for some reason, it does nothing in the setForceVector method.

cpVect is a C struct, does that have anything to do with it?

http://pastebin.com/m78f3d63e

I'm stumped.


Solution

  • This smells very strongly of having two different objects without realizing it. Try logging self in the methods and see if it's the same GameLayer doing all of this.