Hi I hope someone has an idea about this as I've driven myself crazy for two days trying to find it. I'm making an iphone game in objective c with cocos2d and box2d, paddles, balls, bricks nothing too fancy, the paddle handling code worked perfectly both x and y movement I made an addition of radial gravity code in another function but here's where it gets weird. The code isn't called, just sits in a method and it breaks the completely unrelated paddle code.
It's even weirder because I add a nslog in another class, and it switches the mess up from not moving on the x to not moving on the y and starting to move the x. I can comment out random bits of code and it starts to work or rebreak.. I can move the box2d code out and move it and it works or not. Everything is at random.
Does anyone know what could cause this? Is there a maximum method size in objective c I might be overflowing, one method in this class is quite large? Any ideas at all?
Edit- Here's some code, there is a matching if else same code the box bodies are just flipped. There are a lot more just like this with different physics bodies interacting. If I comment both out of any of them it works. Not and it doesn't
Edit double posted the same piece of code
if (spriteA.tag == kSpritePowerUp && spriteB.tag == kSpritePaddle) {
if (std::find(toDestroy.begin(), toDestroy.end(), bodyB) == toDestroy.end()) {
PowerUp *tempPowerUp = (PowerUp*)bodyA->GetUserData();//spriteA;
Paddle* tempPaddle = (Paddle*)bodyB->GetUserData();//spriteB;
[tempPaddle addPowerUp:tempPowerUp];
[self playSoundEffect:kGameSoundPowerUp];
toDestroy.push_back(bodyA);
}
}
EDIT: Solved I went through everything line by line all classes. I ran leaks and found 2. Thanks to everyone. But in the end, it turned out to be 2 local booleans in a utility function that I relied on to be auto-initialized to false. Like it does most times, but sometimes it wouldn't. For no particular reason. Phase of the moon or something.
Sometimes I hate computers