Note that there are some explanatory texts on larger screens.

plurals
  1. POXNA Game - Open a Popup or a Custom Game Screen before launching a game
    text
    copied!<p>Would it be possible to open a custom screen or a popup(modal) in an XNA Game.The idea is to display a few options to the user w.r.t the game and other apps that will be a part of the app suite.</p> <pre><code>public class MyGame : Game { #region Initialization /// &lt;summary&gt; /// Creates a new instance of the game. /// &lt;/summary&gt; public MyGame() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; ///etc; } /// &lt;summary&gt; /// Performs initializations required by the game. /// &lt;/summary&gt; protected override void Initialize() { ///I would Like to open a new screen before the actual game /// menu is displayed ... also return to this screen after the logic is run /// in that screen base.Initialize(); } } </code></pre> <p>Any Ideas/Suggestions/Samples . Thanks in Adv.</p> <p>Krz.</p> <hr> <p>Thanks Blau.I tried the DrawableGameComponent solution(copied the code from an article) but in vain.No matter what I do ,just a blank screen is displayed.</p> <p>In the Game Constructor I put a condition and call the method as </p> <pre><code>if (showScreen) { LaunchScreen launcher = new LaunchScreen(this, null); //Components.Add(launcher); launcher.Show(); } else{///constructor code} </code></pre> <p>I also put a condition in the Game Initialize so that if showScreen is flase then execute.(Not sure if its a proper way to do)</p> <p>The Class looks like this :</p> <pre><code>public class LaunchScreen : DrawableGameComponent { private Texture2D backgroundImage = null; private SpriteBatch spriteBatch = null; public LaunchScreen(Game game, Texture2D texture) : base(game) { backgroundImage = texture; Visible = false; Enabled = false; } public virtual void Show() { Visible = true; Enabled = true; } public virtual void Hide() { Visible = false; Enabled = false; } public override void Initialize() { base.Initialize(); } public override void Update(GameTime gameTime) { base.Update(gameTime); } public override void Draw(GameTime gameTime) { //if (backgroundImage != null) //{ spriteBatch = new SpriteBatch(base.GraphicsDevice); if (Game.Services.GetService(typeof(SpriteBatch)) == null) Game.Services.AddService(typeof(SpriteBatch), spriteBatch); Rectangle screen = new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height); Texture2D lauT2D = this.Game.Content.Load&lt;Texture2D&gt;("Textures/BG"); spriteBatch.Draw(lauT2D, screen, Color.White); //} ///SpriteFont font = this.Game.Content.Load&lt;SpriteFont&gt;("Fonts/MenuFont"); ///Vector2 spritePosition = Vector2.One; ///spriteBatch.DrawString(font, "Goodness ME", spritePosition, Color.White); base.Draw(gameTime); } } </code></pre> <p>I am totally confused on how to initialize the GraphicDevice and the SpriteBatch and open the window before the actual game runs/initializes. Krz</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload