In xNa, if we need to input text, we need to use a soft keyboard. In xNa, guide is used to use a soft keyboard. beginshowkeyboardinput method, because the update of the game will be continuously executed, the guide is required. isvisible to check whether the pop-up input box is displayed.
Guide. beginshowkeyboardinput method parameters
Playerindex indicates the player ID. The mobile phone number is playerindex. One.
Title in the title input window
Description in the input window
Default text
Callback callback Method
Object To be transmitted by the State user
Guide. beginshowmessagebox
Title of the title window
Text in the text window
Buttons button
Buttons preset by foucsbutton
Icon
Callback callback Method
Object To be transmitted by the State user
Example
Using System; Using System. Collections. Generic; Using System. LINQ; Using Microsoft. xNa. Framework; Using Microsoft. xNa. Framework. Audio; Using Microsoft. xNa. Framework. content; Using Microsoft. xNa. Framework. gamerservices; Using Microsoft. xNa. Framework. graphics; Using Microsoft. xNa. Framework. input; Using Microsoft. xNa. Framework. Input. Touch; Using Microsoft. xNa. Framework. Media; Namespace Sipsample { /// <Summary> /// This is the main type for your game /// </Summary> Public Class Game1: Microsoft. xNa. Framework. Game {graphicsdevicemanager graphics; spritebatch; spritefont; String Siptitle = " This is the title. " ; String Sipdescription = " This is the description that goes beneath the title. " ; String Sipresult = " You type stuff here. " ; Public Game1 () {graphics = New Graphicsdevicemanager ( This ); Content. rootdirectory = " Content " ; Targetelapsedtime = Timespan. fromticks (333333 );} Protected Override Void Initialize (){ Base . Initialize ();} Protected Override Void Loadcontent () {spritebatch = New Spritebatch (graphicsdevice); spritefont = Content. Load <spritefont> ( " Spritefont1 " );} Protected Override Void Unloadcontent (){} /// <Summary> /// Input completion callback Method /// </Summary> /// <Param name = "result"> </param> Void Keyboardcallback (iasyncresult result ){ String Retval = Guide. endshowkeyboardinput (result ); If (Retval! = Null ) {Sipresult = Retval ;}} Protected Override Void Update (gametime ){ If (Gamepad. getstate (playerindex. One). Buttons. Back = Buttonstate. Pressed) This . Exit (); // Display the SIP Touchcollection = Touchpanel. getstate (); Foreach (Touchlocation touch In Touchcollection ){ If (Touch. State = Touchlocationstate. Pressed) If (! Guide. isvisible) // The soft keyboard input box is displayed. Guide. beginshowkeyboardinput (playerindex. One, siptitle, sipdescription, sipresult, keyboardcallback, New Object ());} Base . Update (gametime );} Protected Override Void Draw (gametime) {graphicsdevice. Clear (color. cornflowerblue ); // Draw text on the Interface Spritebatch. Begin (); spritebatch. drawstring (spritefont, sipresult, New Vector2 {x = 50 , Y = 200 }, Color. Black); spritebatch. End (); Base . Draw (gametime );}}}