This short recipe is going to demonstrate displaying a message box dialog with an OK or Cancel prompt and show how to handle the user's response.
Load up PlayStation Mobile Studio and create a new project. Add a reference to Sce.PlayStation.HighLevel.UI
. The entire project is available in Ch6_Example4
. Copy the game's existing code from an earlier recipe in this chapter, as we are only going to cover the specifics of creating and interacting with the dialog in this recipe.
Add the following code during the update process to create and display MessageDialog
:
var gamePadData = GamePad.GetData (0); if((gamePadData.Buttons & GamePadButtons.Cross) == GamePadButtons.Cross) { var dialog = MessageDialog.CreateAndShow(MessageDialogStyle.OkCancel,"User Prompts", "Are you sure you wish to continue?"); dialog.ButtonPressed += (sender, e) => { if(dialog.Result == DialogResult.Ok) System.Diagnostics...