my game sometimes freezes

At first my game was only 1 scene and worked good.
Then I added a scene with a menu (newgame, loadgame,etc) and run the gameplay scene from there.

Since then my game sometimes freezes for like 20 seconds and continues….

What could be the problem?

edit: When I dont start the menuscene but just the gameplay like it’s been before the game freezes too :S

Are you preloading anything in that new scene?
Also, you could set up a breakpoint in the scene’s *init()* method and check which ones are causing the lag.

I’ve fixed it. The problem wasnt adding the extra scene.
I just found out about the problem when I added the extra scene so I thought that was it.

It happened when my character would drop down walking off a tile and pressing jump.
The player would double jump while that should only be possible when he initially jumped, so I disabled that and the problem went away.
Not sure what the problem was…

This is the piece of code:

descentCycles = 0;

hasJumped = true;

maxYpos = player~~>getContentSize.height + MAX_JUMP_HEIGHT;
newYpos = player~~>getPosition().y + PIXELS_PLAYER_MOVES;

if(newYpos > maxYpos){
newYpos = maxYpos;
maxJumpReached = true;
}

jumpCycles++;
DURATION_DIVIDER = (int) (4500 / jumpCycles);

rockTile = detectRockCollision(ccp(newXpos, newYpos));
if(rockTile != NULL){
newYpos = rockTile~~>getPosition.y~~ rockTile->getContentSize().height/2;
maxJumpReached = true;
}