Tracking the position of sprite and returning to a scene

Hey Guys, new day...new problems...

I have a menu that comes up when you open the app. and i also have a ball bouncing around, around the edges of the screen, when the ball moves the ball falls off the screen and when it falls off the screen say 100 pixels below the screen, i want my menu to come back up. Do i need to use a
Code:
[self schedule:@selector(ballDropped:) interval:0.0f];
or what do i do? Somehow i need to track the position of the ball and create a if statement of some sort anyway, any help is appreciated thank you! 🙂
You could either check the ball's position directly every frame, or create another body below the screen (as a sensor, so it's not solid), and create a collision callback for when the ball hits that other body.

Or if you're using cocos2d, you could use my new Box2D wrapper to make things way easier:
https://github.com/axcho/CCBox2D

😀
Okay...um...how do i use the wrapper, or the sensor lol the object actually does not collide with anything, the gravity pulls it down basically and it goes off screen, thats when i want it to bring it to my menu scene. ❓
Code:
-(void)ballDropped:(ccTime) dt
{
   CGSize winSize = [CCDirector sharedDirector].winSize;
      if(ball.position.y >= winSize.height + 100) {
         [[CCDirector sharedDirector]replaceScene:[CCTransitionFade transitionWithDuration:1 scene:[HelloWorld node]]];

      }
   
}

that's the thing i wrote. It is suppose to take me to HelloWorld when the position of the ball is 320+100 right?

i call this from (id)init like so...

Code:
[self schedule:@selector(ballDropped:) interval:0.0f];
That looks like it should work, except you need to check if ball.position.y < -100 since in cocos2d the y axis increases upward...

It's not the most efficient way to do it, but it's not a big deal if it works for you. If it doesn't, you might have to look into the more efficient ways I've mentioned. Let me know.

Original thread: https://box2d.org/forum/viewtopic.php?t=6698