Exemple #1
0
        /// <summary>
        /// Draws the animated sprite.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="spriteBatch">The sprite batch.</param>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Save off the previous bounding box before the draw method advances the current frame
            this.PreviousBoundingBox = this.BoundingBox;

            if (this.IsAlive && this._isActive)
            {
                // Flip the sprite to face the way we are moving.
                if (this.Velocity.X > 0)
                {
                    this._flip = SpriteEffects.FlipHorizontally;
                }
                else if (Velocity.X < 0)
                {
                    this._flip = SpriteEffects.None;
                }

                if (!this.IsInvincible || ((int)(this._timeOfInvincibility.TotalMilliseconds / 250) % 2 == 0))
                {
                    this._animationPlayer.Draw(gameTime, spriteBatch, this.Position, this._flip);
                }

#if DEBUG
                // Draw debug outline
                if (ScreenManager.DEBUG_ENABLED)
                {
                    var boundingBox = this.SourceRectangle.HasValue ? this.SourceRectangle.Value : this.Texture.Bounds;
                    boundingBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, boundingBox.Width, boundingBox.Height);
                    DrawingUtils.DrawBorder(spriteBatch, boundingBox, 1, Color.Blue);
                }
#endif
            }
        }
Exemple #2
0
        /// <summary>
        /// Draws the sprite.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="spriteBatch">The sprite batch.</param>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (this.Texture != null)
            {
                spriteBatch.Draw(this.Texture, this.Position, Color.White);

#if DEBUG
                // Draw debug outline
                if (ScreenManager.DEBUG_ENABLED)
                {
                    var boundingBox = this.SourceRectangle.HasValue ? this.SourceRectangle.Value : this.Texture.Bounds;
                    boundingBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, boundingBox.Width, boundingBox.Height);
                    DrawingUtils.DrawBorder(spriteBatch, boundingBox, 1, Color.Yellow);
                }
#endif
            }
        }
        /// <summary>
        /// Draws the sprite.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="spriteBatch">The sprite batch.</param>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            var pixel = new Texture2D(spriteBatch.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);

            pixel.SetData(new[] { this._color });
            spriteBatch.Draw(pixel, this.BoundingBox, Color.White);

#if DEBUG
            // Draw debug outline
            if (ScreenManager.DEBUG_ENABLED)
            {
                var boundingBox = this.SourceRectangle.HasValue ? this.SourceRectangle.Value : this.Texture.Bounds;
                boundingBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, boundingBox.Width, boundingBox.Height);
                DrawingUtils.DrawBorder(spriteBatch, boundingBox, 1, Color.Purple);
            }
#endif
        }
Exemple #4
0
        /// <summary>
        /// Draws the sprite.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="spriteBatch">The sprite batch.</param>
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            // Save off the previous bounding box before the draw method advances the current frame
            this.PreviousBoundingBox = this.BoundingBox;

            if (this.IsActive || (this._spawning && this._drawEnemy))
            {
                var flip = this._direction > 0 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
                this._animationPlayer.Draw(gameTime, spriteBatch, this.Position, flip);

#if DEBUG
                // Draw debug outline
                if (ScreenManager.DEBUG_ENABLED)
                {
                    var boundingBox = this.SourceRectangle.HasValue ? this.SourceRectangle.Value : this.Texture.Bounds;
                    boundingBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, boundingBox.Width, boundingBox.Height);
                    DrawingUtils.DrawBorder(spriteBatch, boundingBox, 1, Color.Red);
                }
#endif
            }
        }
Exemple #5
0
        /// <summary>
        /// Draws the sprite.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <param name="spriteBatch">The sprite batch.</param>
        public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (this.Texture != null)
            {
                spriteBatch.Draw(this.Texture, this.Position, this.SourceRectangle, Color.White);

                //spriteBatch.Draw(this.Texture, this.Position, this.SourceRectangle,
                //    this.TintColor, this.Rotation, this.Origin,
                //    this.Scale, this.Effects, this.LayerDepth);

#if DEBUG
                // Draw debug outline
                if (ScreenManager.DEBUG_ENABLED)
                {
                    var boundingBox = this.SourceRectangle.HasValue ? this.SourceRectangle.Value : this.Texture.Bounds;
                    boundingBox = new Rectangle((int)this.Position.X, (int)this.Position.Y, boundingBox.Width, boundingBox.Height);
                    DrawingUtils.DrawBorder(spriteBatch, boundingBox, 1, Color.White);
                }
#endif
            }
        }