How do UIAlert control join the sio2window

View previous topic View next topic Go down

How do UIAlert control join the sio2window

Post  guola on Tue May 12, 2009 7:40 pm

I would like in the game,
Pop UIAlert Control
Please enter the name of the user

guola

Posts : 3
Join date : 2009-03-05

View user profile

Back to top Go down

Re: How do UIAlert control join the sio2window

Post  yarri on Tue May 12, 2009 9:10 pm

In your ViewController (or ApplicationDelegate if you're using the demo templates) you can make a call to UIKit methods. The question is *when* do you want to display the dialog? For example, you can set up a "game over" timer with something like this in your applicationDidFinishLaunching: method:
Code:

   [NSTimer scheduledTimerWithTimeInterval:(float)gameOverTime target:self selector:@selector(alertShowGameOver:) userInfo:nil repeats:NO];

Where gameOverTime is the duration of your game and alertShowGameOver: is a method like this:
Code:

- (void)alertShowGameOver:(NSTimer *)timer {
   [glView stopAnimation];  // Stop the SIO2 animation, required EAGLView class instantiation
   UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Game Over!" message:@"Play again or quit?" delegate:self cancelButtonTitle:@"Play Again" otherButtonTitles:@"Quit", nil];
   [alert show];  // Show the UIAlert
   [alert release];
}

You'll need to then implement the UIAlertView delegate methods to handle the alert. A similar approach can be used to create modal dialog with a UITextView via a call to presentModalViewController.

--yarri

yarri

Posts : 81
Join date : 2009-04-10

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum