Full-screen mode execution
For performing in full-screen mode, the following codes are added to the constructor of Game1 class.
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // It performs in full-screen mode. graphics.IsFullScreen = true; }
Label:
XNA Tutorial
Exit processing of game
When terminating a game, Game.Exit method is called within a Game1.Update method.
A code is as follows.
protected override void Update(GameTime gameTime) { // Game logic is described here. // A game is ended. if (gameExit) { this.Exit(); return; } base.Update(gameTime); }
Label:
XNA Tutorial
Change of resolution
For changing resolution, the following codes are added to the constructor of Game1 class.
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Change of resolution. graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720; }
Label:
XNA Tutorial
Input(Keyboard, Mouse, GamePad)
A keyboard, a mouse, and Xbox 360 controller can be used in PC.
A keyboard, and Xbox 360 controller can be used in Xbox 360.
Coding.
// Game1.cs using System; using System.Collections.Generic; 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.Net; using Microsoft.Xna.Framework.Storage; namespace Sample { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { } protected override void UnloadContent() { } protected override void Update(GameTime gameTime) { KeyboardState keyboardState = Keyboard.GetState(); MouseState mouseState = Mouse.GetState(); GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); // As an example getting some input state. if (keyboardState.IsKeyDown(Keys.Space)) { // Processing when pushing the space key of a keyboard. } if (mouseState.LeftButton == ButtonState.Pressed) { // Processing when carrying out the left click of the mouse. } if (gamePadState.IsConnected) { if (gamePadState.Buttons.A == ButtonState.Pressed) { // Processing when pushing the A button of a gamepad. } } base.Update(gameTime); } protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); } } }
Label:
XNA Tutorial
Subscribe to:
Posts (Atom)