diff --git a/axios/Engine/SimpleAxiosGameObject.cs b/axios/Engine/SimpleAxiosGameObject.cs index 2392323..9e1f88c 100644 --- a/axios/Engine/SimpleAxiosGameObject.cs +++ b/axios/Engine/SimpleAxiosGameObject.cs @@ -18,6 +18,13 @@ namespace Axios.Engine public bool ApplyConstantVelocity = false; public Vector2 ConstantVelocity; + private bool _allowmousejoint = false; + public bool AllowAutomaticMouseJoint + { + get { return _allowmousejoint; } + set { _allowmousejoint = value; } + } + public SimpleAxiosGameObject() { AxiosLog.Instance.AddLine("[Axios Engine] - Creating SimpleAxiosGameObject " + Name, LoggingFlag.DEBUG); diff --git a/axios/ScreenSystem/PhysicsGameScreen.cs b/axios/ScreenSystem/PhysicsGameScreen.cs index 03b502f..30fc9f0 100644 --- a/axios/ScreenSystem/PhysicsGameScreen.cs +++ b/axios/ScreenSystem/PhysicsGameScreen.cs @@ -6,6 +6,7 @@ using FarseerPhysics.Dynamics.Joints; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Input; +using Axios.Engine; namespace FarseerPhysics.SamplesFramework { @@ -17,17 +18,20 @@ namespace FarseerPhysics.SamplesFramework private float _agentForce; private float _agentTorque; -#if DEBUG private FixedMouseJoint _fixedMouseJoint; -#endif private Body _userAgent; protected PhysicsGameScreen() { TransitionOnTime = TimeSpan.FromSeconds(0.75); TransitionOffTime = TimeSpan.FromSeconds(0.75); - HasCursor = true; +#if DEBUG EnableCameraControl = true; + HasCursor = true; +#else + EnableCameraControl = false; + HasCursor = false; +#endif _userAgent = null; World = null; Camera = null; @@ -157,39 +161,39 @@ namespace FarseerPhysics.SamplesFramework EnableOrDisableFlag(DebugViewFlags.AABB); } - if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape)) +#endif + + if (_userAgent != null) { - if (this.ScreenState == SamplesFramework.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1) - { //Give the screens a chance to transition + HandleUserAgent(input); + } - CleanUp(); - ExitScreen(); - - } + if (EnableCameraControl) + { + HandleCamera(input, gameTime); } + if (HasCursor) { HandleCursor(input); } - if (_userAgent != null) + if (input.IsNewButtonPress(Buttons.Back) || input.IsNewKeyPress(Keys.Escape)) { - HandleUserAgent(input); - } + if (this.ScreenState == SamplesFramework.ScreenState.Active && this.TransitionPosition == 0 && this.TransitionAlpha == 1) + { //Give the screens a chance to transition - if (EnableCameraControl) - { - HandleCamera(input, gameTime); - } -#endif + CleanUp(); + ExitScreen(); + } + } base.HandleInput(input, gameTime); } public virtual void HandleCursor(InputHelper input) { - #if DEBUG Vector2 position = Camera.ConvertScreenToWorld(input.Cursor); if ((input.IsNewButtonPress(Buttons.A) || @@ -197,7 +201,7 @@ namespace FarseerPhysics.SamplesFramework _fixedMouseJoint == null) { Fixture savedFixture = World.TestPoint(position); - if (savedFixture != null) + if (savedFixture != null && savedFixture.UserData is SimpleAxiosGameObject && ((SimpleAxiosGameObject)(savedFixture.UserData)).AllowAutomaticMouseJoint) { Body body = savedFixture.Body; _fixedMouseJoint = new FixedMouseJoint(body, position); @@ -219,14 +223,14 @@ namespace FarseerPhysics.SamplesFramework { _fixedMouseJoint.WorldAnchorB = position; } - #endif + } private void HandleCamera(InputHelper input, GameTime gameTime) { Vector2 camMove = Vector2.Zero; -#if DEBUG + if (input.KeyboardState.IsKeyDown(Keys.Up)) { camMove.Y -= 10f * (float)gameTime.ElapsedGameTime.TotalSeconds; @@ -259,12 +263,12 @@ namespace FarseerPhysics.SamplesFramework { Camera.ResetCamera(); } -#endif + } private void HandleUserAgent(InputHelper input) { -#if DEBUG + Vector2 force = _agentForce * new Vector2(input.GamePadState.ThumbSticks.Right.X, -input.GamePadState.ThumbSticks.Right.Y); float torque = _agentTorque * (input.GamePadState.Triggers.Right - input.GamePadState.Triggers.Left); @@ -304,7 +308,7 @@ namespace FarseerPhysics.SamplesFramework _userAgent.ApplyForce(force); _userAgent.ApplyTorque(torque); -#endif + } private void EnableOrDisableFlag(DebugViewFlags flag)