Initial tests are looking good, cursor seems to be the only thing that doesn't work.
Tested with Axios Tennis and the new menu looks pretty slick. --HG-- branch : axios-newgsm
This commit is contained in:
parent
7cc7e9130c
commit
bf3950b0c5
@ -235,6 +235,7 @@
|
|||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="system.data.linq, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
|
<Reference Include="system.data.linq, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System.Net" />
|
<Reference Include="System.Net" />
|
||||||
|
<Reference Include="System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, processorArchitecture=MSIL" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
<Reference Include="System.Xml.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||||
@ -243,7 +244,7 @@
|
|||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!--
|
<!--
|
||||||
|
@ -242,7 +242,6 @@
|
|||||||
<Compile Include="ScreenSystem\GameScreen.cs" />
|
<Compile Include="ScreenSystem\GameScreen.cs" />
|
||||||
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
||||||
<Compile Include="ScreenSystem\InputAction.cs" />
|
<Compile Include="ScreenSystem\InputAction.cs" />
|
||||||
<Compile Include="ScreenSystem\InputHelper.cs" />
|
|
||||||
<Compile Include="Engine\AxiosGameScreen.cs" />
|
<Compile Include="Engine\AxiosGameScreen.cs" />
|
||||||
<Compile Include="ScreenSystem\InputState.cs" />
|
<Compile Include="ScreenSystem\InputState.cs" />
|
||||||
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
||||||
@ -274,7 +273,7 @@
|
|||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
<PostBuildEvent>if not exist "$(TargeDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!--
|
<!--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ProjectView>ProjectFiles</ProjectView>
|
<ProjectView>ShowAllFiles</ProjectView>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -191,7 +191,6 @@
|
|||||||
<Compile Include="ScreenSystem\GameScreen.cs" />
|
<Compile Include="ScreenSystem\GameScreen.cs" />
|
||||||
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
<Compile Include="ScreenSystem\IDemoScreen.cs" />
|
||||||
<Compile Include="ScreenSystem\InputAction.cs" />
|
<Compile Include="ScreenSystem\InputAction.cs" />
|
||||||
<Compile Include="ScreenSystem\InputHelper.cs" />
|
|
||||||
<Compile Include="ScreenSystem\InputState.cs" />
|
<Compile Include="ScreenSystem\InputState.cs" />
|
||||||
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
<Compile Include="ScreenSystem\IScreenFactory.cs" />
|
||||||
<Compile Include="ScreenSystem\LoadingScreen.cs" />
|
<Compile Include="ScreenSystem\LoadingScreen.cs" />
|
||||||
@ -238,7 +237,7 @@
|
|||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PostBuildEvent>if not exist "$(TargetPath)" ..\..\Combined mkdir "$(TargetPath)" ..\..\Combined
|
<PostBuildEvent>if not exist "$(TargetDir)"..\..\Combined mkdir "$(TargetDir)"..\..\Combined
|
||||||
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
copy "$(TargetPath)" ..\..\Combined</PostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<!--
|
<!--
|
||||||
|
@ -336,7 +336,7 @@ namespace Axios.Engine
|
|||||||
|
|
||||||
public override void HandleInput(GameTime gameTime, InputState input)
|
public override void HandleInput(GameTime gameTime, InputState input)
|
||||||
{
|
{
|
||||||
base.HandleInput(input, gameTime);
|
base.HandleInput(gameTime, input);
|
||||||
|
|
||||||
foreach (AxiosGameObject g in _gameObjects.ToList())
|
foreach (AxiosGameObject g in _gameObjects.ToList())
|
||||||
g.HandleInput(this, input, gameTime);
|
g.HandleInput(this, input, gameTime);
|
||||||
@ -347,7 +347,7 @@ namespace Axios.Engine
|
|||||||
|
|
||||||
public override void Deactivate()
|
public override void Deactivate()
|
||||||
{
|
{
|
||||||
base.UnloadContent();
|
base.Deactivate();
|
||||||
//AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
//AxiosLog.Instance.AddLine("Memory usage before cleanup: " + GC.GetTotalMemory(true).ToString(), LoggingFlag.DEBUG);
|
||||||
foreach (AxiosGameObject g in _gameObjects)
|
foreach (AxiosGameObject g in _gameObjects)
|
||||||
g.UnloadContent(this);
|
g.UnloadContent(this);
|
||||||
|
@ -22,7 +22,7 @@ namespace GameStateManagement
|
|||||||
/// It draws a background image that remains fixed in place regardless
|
/// It draws a background image that remains fixed in place regardless
|
||||||
/// of whatever transitions the screens on top of it may be doing.
|
/// of whatever transitions the screens on top of it may be doing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class BackgroundScreen : GameScreen
|
public class BackgroundScreen : GameScreen
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
@ -35,6 +35,12 @@ namespace GameStateManagement
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class GameScreen
|
public abstract class GameScreen
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public GameScreen()
|
||||||
|
{
|
||||||
|
HasVirtualStick = false;
|
||||||
|
HasCursor = false;
|
||||||
|
}
|
||||||
protected bool HasCursor = false;
|
protected bool HasCursor = false;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Normally when one screen is brought up over the top of another,
|
/// Normally when one screen is brought up over the top of another,
|
||||||
@ -50,7 +56,7 @@ namespace GameStateManagement
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isPopup = false;
|
bool isPopup = false;
|
||||||
|
public bool HasVirtualStick { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates how long the screen takes to
|
/// Indicates how long the screen takes to
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using Microsoft.Xna.Framework.Input.Touch;
|
using Microsoft.Xna.Framework.Input.Touch;
|
||||||
|
using FarseerPhysics.SamplesFramework;
|
||||||
using GameStateManagement;
|
using GameStateManagement;
|
||||||
|
|
||||||
namespace FarseerPhysics.SamplesFramework
|
namespace FarseerPhysics.SamplesFramework2
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// an enum of all available mouse buttons.
|
/// an enum of all available mouse buttons.
|
||||||
@ -147,13 +149,13 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
public void LoadContent()
|
public void LoadContent()
|
||||||
{
|
{
|
||||||
|
|
||||||
_cursorSprite = new Sprite(_manager.Content.Load<Texture2D>("Common/cursor"));
|
_cursorSprite = new Sprite(_manager.Game.Content.Load<Texture2D>("Common/cursor"));
|
||||||
#if WINDOWS_PHONE
|
#if WINDOWS_PHONE
|
||||||
// virtual stick content
|
// virtual stick content
|
||||||
_phoneStick = new VirtualStick(_manager.Content.Load<Texture2D>("Common/socket"),
|
_phoneStick = new VirtualStick(_manager.Game.Content.Load<Texture2D>("Common/socket"),
|
||||||
_manager.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
|
_manager.Game.Content.Load<Texture2D>("Common/stick"), new Vector2(80f, 400f));
|
||||||
|
|
||||||
Texture2D temp = _manager.Content.Load<Texture2D>("Common/buttons");
|
Texture2D temp = _manager.Game.Content.Load<Texture2D>("Common/buttons");
|
||||||
_phoneA = new VirtualButton(temp, new Vector2(695f, 380f), new Rectangle(0, 0, 40, 40), new Rectangle(0, 40, 40, 40));
|
_phoneA = new VirtualButton(temp, new Vector2(695f, 380f), new Rectangle(0, 0, 40, 40), new Rectangle(0, 40, 40, 40));
|
||||||
_phoneB = new VirtualButton(temp, new Vector2(745f, 360f), new Rectangle(40, 0, 40, 40), new Rectangle(40, 40, 40, 40));
|
_phoneB = new VirtualButton(temp, new Vector2(745f, 360f), new Rectangle(40, 0, 40, 40), new Rectangle(40, 40, 40, 40));
|
||||||
#endif
|
#endif
|
||||||
|
@ -432,6 +432,28 @@ namespace GameStateManagement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsNewKeyRelease(Keys key, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
|
||||||
|
{
|
||||||
|
if (controllingPlayer.HasValue)
|
||||||
|
{
|
||||||
|
// Read input from the specified player.
|
||||||
|
playerIndex = controllingPlayer.Value;
|
||||||
|
|
||||||
|
int i = (int)playerIndex;
|
||||||
|
|
||||||
|
return (CurrentKeyboardStates[i].IsKeyUp(key) &&
|
||||||
|
LastKeyboardStates[i].IsKeyDown(key));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Accept input from any player.
|
||||||
|
return (IsNewKeyRelease(key, PlayerIndex.One, out playerIndex) ||
|
||||||
|
IsNewKeyRelease(key, PlayerIndex.Two, out playerIndex) ||
|
||||||
|
IsNewKeyRelease(key, PlayerIndex.Three, out playerIndex) ||
|
||||||
|
IsNewKeyRelease(key, PlayerIndex.Four, out playerIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper for checking if a button was newly pressed during this update.
|
/// Helper for checking if a button was newly pressed during this update.
|
||||||
@ -461,6 +483,28 @@ namespace GameStateManagement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsNewButtonRelease(Buttons button, PlayerIndex? controllingPlayer, out PlayerIndex playerIndex)
|
||||||
|
{
|
||||||
|
if (controllingPlayer.HasValue)
|
||||||
|
{
|
||||||
|
// Read input from the specified player.
|
||||||
|
playerIndex = controllingPlayer.Value;
|
||||||
|
|
||||||
|
int i = (int)playerIndex;
|
||||||
|
|
||||||
|
return (CurrentGamePadStates[i].IsButtonUp(button) &&
|
||||||
|
LastGamePadStates[i].IsButtonDown(button));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Accept input from any player.
|
||||||
|
return (IsNewButtonRelease(button, PlayerIndex.One, out playerIndex) ||
|
||||||
|
IsNewButtonRelease(button, PlayerIndex.Two, out playerIndex) ||
|
||||||
|
IsNewButtonRelease(button, PlayerIndex.Three, out playerIndex) ||
|
||||||
|
IsNewButtonRelease(button, PlayerIndex.Four, out playerIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsNewVirtualButtonPress(Buttons button)
|
public bool IsNewVirtualButtonPress(Buttons button)
|
||||||
{
|
{
|
||||||
return (_lastVirtualState.IsButtonUp(button) &&
|
return (_lastVirtualState.IsButtonUp(button) &&
|
||||||
|
@ -22,7 +22,7 @@ namespace GameStateManagement
|
|||||||
/// entries in different ways. This also provides an event that will be raised
|
/// entries in different ways. This also provides an event that will be raised
|
||||||
/// when the menu entry is selected.
|
/// when the menu entry is selected.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class MenuEntry
|
public class MenuEntry
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@ namespace GameStateManagement
|
|||||||
/// Base class for screens that contain a menu of options. The user can
|
/// Base class for screens that contain a menu of options. The user can
|
||||||
/// move up and down to select an entry, or cancel to back out of the screen.
|
/// move up and down to select an entry, or cancel to back out of the screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
abstract class MenuScreen : GameScreen
|
public class MenuScreen : GameScreen
|
||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
List<MenuEntry> menuEntries = new List<MenuEntry>();
|
private List<MenuEntry> menuEntries = new List<MenuEntry>();
|
||||||
int selectedEntry = 0;
|
int selectedEntry = 0;
|
||||||
string menuTitle;
|
string menuTitle;
|
||||||
|
|
||||||
@ -87,6 +87,12 @@ namespace GameStateManagement
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void AddMenuItem(string name)
|
||||||
|
{
|
||||||
|
|
||||||
|
menuEntries.Add(new MenuEntry(name));
|
||||||
|
}
|
||||||
|
|
||||||
#region Handle Input
|
#region Handle Input
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,7 +185,8 @@ namespace GameStateManagement
|
|||||||
HandleCursor(input);
|
HandleCursor(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape))
|
PlayerIndex i;
|
||||||
|
if (input.IsNewButtonPress(Buttons.Back, PlayerIndex.One, out i) || input.IsNewKeyPress(Keys.Escape, PlayerIndex.One, out i))
|
||||||
{
|
{
|
||||||
if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
|
if (this.ScreenState == GameStateManagement.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1)
|
||||||
{ //Give the screens a chance to transition
|
{ //Give the screens a chance to transition
|
||||||
@ -195,7 +196,7 @@ namespace GameStateManagement
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
base.HandleInput(input, gameTime);
|
base.HandleInput(gameTime, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void HandleCursor(InputState input)
|
public virtual void HandleCursor(InputState input)
|
||||||
@ -203,7 +204,7 @@ namespace GameStateManagement
|
|||||||
PlayerIndex player;
|
PlayerIndex player;
|
||||||
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
|
Vector2 position = Camera.ConvertScreenToWorld(input.Cursor);
|
||||||
|
|
||||||
if ((input.IsNewButtonPress(Buttons.A) ||
|
if ((input.IsNewButtonPress(Buttons.A, PlayerIndex.One, out player) ||
|
||||||
input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
|
input.IsNewMouseButtonPress(MouseButtons.LeftButton)) &&
|
||||||
_fixedMouseJoint == null)
|
_fixedMouseJoint == null)
|
||||||
{
|
{
|
||||||
@ -220,7 +221,7 @@ namespace GameStateManagement
|
|||||||
|
|
||||||
|
|
||||||
if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
|
if ((input.IsNewButtonRelease(Buttons.A, ControllingPlayer.Value, out player) ||
|
||||||
input.IsNewMouseButtonRelease(MouseButtons.LeftButton, ControllingPlayer.Value, out player)) &&
|
input.IsNewMouseButtonRelease(MouseButtons.LeftButton)) &&
|
||||||
_fixedMouseJoint != null)
|
_fixedMouseJoint != null)
|
||||||
{
|
{
|
||||||
World.RemoveJoint(_fixedMouseJoint);
|
World.RemoveJoint(_fixedMouseJoint);
|
||||||
@ -234,32 +235,32 @@ namespace GameStateManagement
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleCamera(InputHelper input, GameTime gameTime)
|
private void HandleCamera(InputState input, GameTime gameTime)
|
||||||
{
|
{
|
||||||
Vector2 camMove = Vector2.Zero;
|
Vector2 camMove = Vector2.Zero;
|
||||||
|
|
||||||
|
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Up))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Up))
|
||||||
{
|
{
|
||||||
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Down))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Down))
|
||||||
{
|
{
|
||||||
camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
camMove.Y += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Left))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Left))
|
||||||
{
|
{
|
||||||
camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
camMove.X -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Right))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Right))
|
||||||
{
|
{
|
||||||
camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
camMove.X += 10f * (float)gameTime.ElapsedGameTime.TotalSeconds;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.PageUp))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageUp))
|
||||||
{
|
{
|
||||||
Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
Camera.Zoom += 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.PageDown))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.PageDown))
|
||||||
{
|
{
|
||||||
Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
Camera.Zoom -= 5f * (float)gameTime.ElapsedGameTime.TotalSeconds * Camera.Zoom / 20f;
|
||||||
}
|
}
|
||||||
@ -267,19 +268,20 @@ namespace GameStateManagement
|
|||||||
{
|
{
|
||||||
Camera.MoveCamera(camMove);
|
Camera.MoveCamera(camMove);
|
||||||
}
|
}
|
||||||
if (input.IsNewKeyPress(Keys.Home))
|
PlayerIndex i;
|
||||||
|
if (input.IsNewKeyPress(Keys.Home, PlayerIndex.One, out i))
|
||||||
{
|
{
|
||||||
Camera.ResetCamera();
|
Camera.ResetCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleUserAgent(InputHelper input)
|
private void HandleUserAgent(InputState input)
|
||||||
{
|
{
|
||||||
|
|
||||||
Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X,
|
Vector2 force = _agentForce * new Vector2(input.CurrentGamePadStates[0].ThumbSticks.Right.X,
|
||||||
-input.GamePadState.ThumbSticks.Right.Y);
|
-input.CurrentGamePadStates[0].ThumbSticks.Right.Y);
|
||||||
float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left);
|
float torque = _agentTorque * (input.CurrentGamePadStates[0].Triggers.Right - input.CurrentGamePadStates[0].Triggers.Left);
|
||||||
|
|
||||||
_userAgent.ApplyForce(force);
|
_userAgent.ApplyForce(force);
|
||||||
_userAgent.ApplyTorque(torque);
|
_userAgent.ApplyTorque(torque);
|
||||||
@ -289,27 +291,27 @@ namespace GameStateManagement
|
|||||||
force = Vector2.Zero;
|
force = Vector2.Zero;
|
||||||
torque = 0;
|
torque = 0;
|
||||||
|
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.A))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.A))
|
||||||
{
|
{
|
||||||
force += new Vector2(-forceAmount, 0);
|
force += new Vector2(-forceAmount, 0);
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.S))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.S))
|
||||||
{
|
{
|
||||||
force += new Vector2(0, forceAmount);
|
force += new Vector2(0, forceAmount);
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.D))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.D))
|
||||||
{
|
{
|
||||||
force += new Vector2(forceAmount, 0);
|
force += new Vector2(forceAmount, 0);
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.W))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.W))
|
||||||
{
|
{
|
||||||
force += new Vector2(0, -forceAmount);
|
force += new Vector2(0, -forceAmount);
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.Q))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.Q))
|
||||||
{
|
{
|
||||||
torque -= _agentTorque;
|
torque -= _agentTorque;
|
||||||
}
|
}
|
||||||
if (input.KeyboardState.IsKeyDown(Keys.E))
|
if (input.CurrentKeyboardStates[0].IsKeyDown(Keys.E))
|
||||||
{
|
{
|
||||||
torque += _agentTorque;
|
torque += _agentTorque;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace GameStateManagement
|
|||||||
/// Custom event argument which includes the index of the player who
|
/// Custom event argument which includes the index of the player who
|
||||||
/// triggered the event. This is used by the MenuEntry.Selected event.
|
/// triggered the event. This is used by the MenuEntry.Selected event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class PlayerIndexEventArgs : EventArgs
|
public class PlayerIndexEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
|
@ -139,11 +139,11 @@ namespace GameStateManagement
|
|||||||
protected override void LoadContent()
|
protected override void LoadContent()
|
||||||
{
|
{
|
||||||
// Load content belonging to the screen manager.
|
// Load content belonging to the screen manager.
|
||||||
ContentManager content = Game.Content;
|
ContentManager content = new ContentManager(this.Game.Services, "Content/Fonts");
|
||||||
|
_spriteFonts = new SpriteFonts(content);
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
font = content.Load<SpriteFont>("menufont");
|
font = content.Load<SpriteFont>("menufont");
|
||||||
blankTexture = content.Load<Texture2D>("blank");
|
blankTexture = Game.Content.Load<Texture2D>("Materials/blank");
|
||||||
|
|
||||||
// Tell each of the screens to load their content.
|
// Tell each of the screens to load their content.
|
||||||
foreach (GameScreen screen in screens)
|
foreach (GameScreen screen in screens)
|
||||||
@ -177,7 +177,7 @@ namespace GameStateManagement
|
|||||||
public override void Update(GameTime gameTime)
|
public override void Update(GameTime gameTime)
|
||||||
{
|
{
|
||||||
// Read the keyboard and gamepad.
|
// Read the keyboard and gamepad.
|
||||||
input.Update();
|
input.Update(gameTime);
|
||||||
|
|
||||||
// Make a copy of the master screen list, to avoid confusion if
|
// Make a copy of the master screen list, to avoid confusion if
|
||||||
// the process of updating one screen adds or removes others.
|
// the process of updating one screen adds or removes others.
|
||||||
|
@ -11,9 +11,9 @@ namespace FarseerPhysics.SamplesFramework
|
|||||||
|
|
||||||
public SpriteFonts(ContentManager contentManager)
|
public SpriteFonts(ContentManager contentManager)
|
||||||
{
|
{
|
||||||
MenuSpriteFont = contentManager.Load<SpriteFont>("Fonts/menuFont");
|
MenuSpriteFont = contentManager.Load<SpriteFont>("menuFont");
|
||||||
FrameRateCounterFont = contentManager.Load<SpriteFont>("Fonts/frameRateCounterFont");
|
FrameRateCounterFont = contentManager.Load<SpriteFont>("frameRateCounterFont");
|
||||||
DetailsFont = contentManager.Load<SpriteFont>("Fonts/detailsFont");
|
DetailsFont = contentManager.Load<SpriteFont>("detailsFont");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user