|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FarseerXNADemo3.Screens
{
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using FarseerXNABase.ScreenSystem;
using Microsoft.Xna.Framework.Input;
public class InstructionsScreen : GameScreen
{
#region Properties & Variables
private ContentManager _content;
private Rectangle _viewport;
private Texture2D _texture;
#endregion
#region Initialization and Load
public InstructionsScreen()
{
TransitionOnTime = TimeSpan.FromSeconds(0.5);
TransitionOffTime = TimeSpan.FromSeconds(0.5);
this.IsPopup = true;
}
public override void LoadContent()
{
if (_content == null)
_content = new ContentManager(ScreenManager.Game.Services, "Content");
_texture = ScreenManager.ContentManager.Load<Texture2D>("instructions");
UpdateScreen();
ScreenManager.Camera.ProjectionUpdated += UpdateScreen;
base.LoadContent();
}
public override void UnloadContent()
{
_content.Unload();
}
private void UpdateScreen()
{
Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
_viewport = new Rectangle(0, 0, viewport.Width, viewport.Height);
}
#endregion
#region Game Methods
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
{
// Allows popup to be closed by back button
if (this.IsActive && GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
{
this.ExitScreen();
}
base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
}
public override void Draw(GameTime gameTime)
{
ScreenManager.SpriteBatch.Begin();
ScreenManager.SpriteBatch.Draw(_texture, new Vector2(_viewport.Width / 2 - _texture.Width / 2, _viewport.Height / 2 - _texture.Height / 2), Color.White);
ScreenManager.SpriteBatch.End();
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Love Programming... and games. You can find latest about me over http://www.veloxcore.com/