コード例 #1
0
        protected PhysicsFrame getCurrentPhysicsFrame()
        {
            int          index        = GetCurrentFrameIndex();
            PhysicsFrame currentFrame = frames[0];

            return(currentFrame);
        }
コード例 #2
0
        public override void Draw(GameTime gameTime)
        {
            PhysicsFrame currentFrame    = getCurrentPhysicsFrame();
            Rectangle    sourceRectangle = GetCurrentFrameRectangle();

            this.game.SpriteBatch.Draw(spriteSheet.Texture, DisplayPosition, sourceRectangle, OverlayColor, Body.Rotation, currentFrame.Offset, Scale, SpriteEffects.None, LayerDepth);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }