Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | using System; using Axios.Engine.Log; using FarseerPhysics.Dynamics; using Microsoft.Xna.Framework; namespace Axios.Engine { public abstract class SimpleAxiosGameObject : AxiosGameObject { public Body BodyPart; public Vector2 Position; public Vector2 Origin; 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); Position = new Vector2(); } public override void UnloadContent(AxiosGameScreen gameScreen) { AxiosLog.Instance.AddLine( "[Axios Engine] - Unloading SimpleAxiosGameObject " + Name, LoggingFlag.DEBUG); base .UnloadContent(gameScreen); gameScreen.World.RemoveBody(BodyPart); } public override void Update(AxiosGameScreen gameScreen, GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen) { base .Update(gameScreen, gameTime, otherScreenHasFocus, coveredByOtherScreen); if (ApplyConstantVelocity) { if (Math.Abs(BodyPart.LinearVelocity.X) > ConstantVelocity.X || Math.Abs(BodyPart.LinearVelocity.X) < ConstantVelocity.X) { //Figure which direction it's going and adjust if (Math.Abs(BodyPart.LinearVelocity.X) > BodyPart.LinearVelocity.X) //negative BodyPart.LinearVelocity = new Vector2(-ConstantVelocity.X, BodyPart.LinearVelocity.Y); else BodyPart.LinearVelocity = new Vector2(ConstantVelocity.X, BodyPart.LinearVelocity.Y); } if (Math.Abs(BodyPart.LinearVelocity.Y) > ConstantVelocity.Y || Math.Abs(BodyPart.LinearVelocity.Y) < ConstantVelocity.Y) { //Figure which direction it's going and adjust if (Math.Abs(BodyPart.LinearVelocity.Y) > BodyPart.LinearVelocity.Y) //negative BodyPart.LinearVelocity = new Vector2(BodyPart.LinearVelocity.X, -ConstantVelocity.Y); else BodyPart.LinearVelocity = new Vector2(BodyPart.LinearVelocity.X, ConstantVelocity.Y); } } } } } |
Source at commit Version_1.0.1.9 created 11 years 7 months ago. By Nathan Adams, Incrementing version |
---|