예제 #1
0
        /// <summary>
        /// Converts image data to physics fixtures, and initializes default values
        /// </summary>
        public virtual void InitializePhysics()
        {
            Body          = new Body(game.Physics);
            Body.UserData = this;

            PhysicsFrame easyVertices = PhysicsHelper.GetVerticesForTexture(texture);

            FixtureFactory.AttachCompoundPolygon(easyVertices.Vertices, 1f, Body);
            offset = easyVertices.Offset;

            Body.Mass = 1f;

            PhysicsHelper.AttachOnCollisionHandlers(Body, game);
        }
예제 #2
0
        public override void InitializePhysics()
        {
            Body               = new Body(game.Physics);
            Body.UserData      = this;
            Body.BodyType      = BodyType.Dynamic;
            Body.FixedRotation = true;
            frames             = new List <PhysicsFrame>();

            PhysicsFrame   frame    = PhysicsHelper.GetVerticesForTexture(spriteSheet, 0);
            List <Fixture> fixtures = FixtureFactory.AttachCompoundPolygon(frame.Vertices, 1f, Body);

            frame.Fixtures = fixtures;
            frames.Add(frame);
            PhysicsHelper.AttachOnCollisionHandlers(Body, game);
        }
예제 #3
0
 public Rectangle GetBoundingBox()
 {
     return(PhysicsHelper.GetAABB(this));
 }