public override void Draw(GameCanvas g)
            {
                SpriteEffects flip = facingRight ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

                // Determine what to draw, then do it
                if (isGrounded && body.LinearVelocity.Length() > 0.1f)
                {
                    texture = walking;
                    g.DrawSprite(texture, Color.White, Position, scale, rotation, frame, MAX_FRAME, flip);
                }
                else
                {
                    texture = standing;
                    if (body.LinearVelocity.Y < 0.0f) texture = jumping;
                    if (body.LinearVelocity.Y > 0.0f) texture = falling;

                    g.DrawSprite(texture, Color.White, Position, scale, rotation, flip);
                }
            }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            canvas.Reset();
            canvas.BeginSpritePass(BlendState.AlphaBlend);
            canvas.DrawSprite(background, Color.White, new Vector2(background.Width, background.Height) / scale / 2, Vector2.One / scale, 0);
            foreach (Object o in objects)
            {
                o.Draw(canvas);
            }
            canvas.EndSpritePass();

            base.Draw(gameTime);
        }
Beispiel #3
0
 /// <summary>
 /// Draws the physics object.
 /// </summary>
 /// <param name="canvas">Drawing context</param>
 public virtual void Draw(GameCanvas g)
 {
     g.DrawSprite(texture, Color.White, Position, scale, rotation);
 }
Beispiel #4
0
 /// <summary>
 /// Draws the physics object.
 /// </summary>
 /// <param name="canvas">Drawing context</param>
 public virtual void Draw(GameCanvas g)
 {
     g.DrawSprite(texture, Color.White, Position, scale, rotation);
 }
        public override void Draw(GameCanvas g)
        {
            SpriteEffects flip = facingRight ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

                // Determine what to draw, then do it
                if (isGrounded && body.LinearVelocity.Length() > 0.1f)
                {
                    texture = walking;
                    g.DrawSprite(texture, Color.White, Position, scale, rotation, frame, MAX_FRAME, flip);
                }
                else
                {
                    texture = standing;
                    if (body.LinearVelocity.Y < 0.0f) texture = jumping;
                    if (body.LinearVelocity.Y > 0.0f) texture = falling;

                    g.DrawSprite(texture, Color.White, Position, scale, rotation, flip);
                }
        }