Adding Deactivate event for when the screen leaves focus

Added flag to enable/disable moving camera with gamepad
This commit is contained in:
Nathan Adams 2015-01-04 16:40:19 -06:00
parent d924498cb6
commit e23503cd00
3 changed files with 7 additions and 3 deletions

View File

@ -140,6 +140,8 @@
* - Adding dispose methods to AxiosFile objects * - Adding dispose methods to AxiosFile objects
* - Adding extended log to AxiosLog * - Adding extended log to AxiosLog
* - Fixing issue in CommandConsole where the first line would not be displayed * - Fixing issue in CommandConsole where the first line would not be displayed
* - Adding Deactivate event for when the screen leaves focus
* - Added flag to enable/disable moving camera with gamepad
* *
*/ */
#endregion #endregion

View File

@ -330,9 +330,10 @@ namespace Axios.Engine
public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
{ {
if (otherScreenHasFocus) if (otherScreenHasFocus && !screenHidden)
{ {
screenHidden = true; screenHidden = true;
this.Deactivate();
} }
if (screenHidden && !otherScreenHasFocus) if (screenHidden && !otherScreenHasFocus)
@ -508,7 +509,6 @@ namespace Axios.Engine
{ {
//this.IsExiting = true; //this.IsExiting = true;
//System.Diagnostics.Debugger.Break(); //System.Diagnostics.Debugger.Break();
base.Deactivate();
ScreenState = GameStateManagement.ScreenState.TransitionOff; ScreenState = GameStateManagement.ScreenState.TransitionOff;
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)
@ -538,6 +538,7 @@ namespace Axios.Engine
} }
#endif #endif
} }

View File

@ -104,6 +104,7 @@ namespace GameStateManagement
* -- Nathan Adams [adamsna@datanethost.net] - 4/12/2012 * -- Nathan Adams [adamsna@datanethost.net] - 4/12/2012
*/ */
public bool MoveCursorWithController = false;
/* /*
* Adding variables for the cursor * Adding variables for the cursor
@ -391,7 +392,7 @@ namespace GameStateManagement
// Update cursor // Update cursor
Vector2 oldCursor = _cursor; Vector2 oldCursor = _cursor;
if (CurrentGamePadStates[0].IsConnected && CurrentGamePadStates[0].ThumbSticks.Left != Vector2.Zero) if (CurrentGamePadStates[0].IsConnected && CurrentGamePadStates[0].ThumbSticks.Left != Vector2.Zero && MoveCursorWithController)
{ {
Vector2 temp = CurrentGamePadStates[0].ThumbSticks.Left; Vector2 temp = CurrentGamePadStates[0].ThumbSticks.Left;
_cursor += temp * new Vector2(300f, -300f) * (float)gameTime.ElapsedGameTime.TotalSeconds; _cursor += temp * new Vector2(300f, -300f) * (float)gameTime.ElapsedGameTime.TotalSeconds;