public void DrawSprite(SpriteBatch spriteBatch)
 {
     // DrawParallax the first quad
     spriteBatch.Draw(texture, firstQuadPos + screenCenter, firstQuadRegion, Color.White, 0f, firstQuadOrigin, 1f, SpriteEffects.None, ImageOrientation.AsIs, depth);
     
     if (secondQuadRegion.Width > 0)
     {
         // DrawParallax the second quad
         spriteBatch.Draw(texture, secondQuadPos + screenCenter, secondQuadRegion, Color.White, 0f, secondQuadOrigin, 1f, SpriteEffects.None, ImageOrientation.AsIs, depth);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Draw a sprite using a sprite batch.
        /// </summary>
        /// <param name="sprite">The sprite</param>
        /// <param name="spriteBatch">The sprite batch used to draw the sprite.</param>
        /// <param name="position">The position to which draw the sprite</param>
        /// <param name="color">The color to use to draw the sprite</param>
        /// <param name="rotation">The rotation to apply on the sprite</param>
        /// <param name="scales">The scale factors to apply on the sprite</param>
        /// <param name="depthLayer">The depth layer to which draw the sprite</param>
        /// <param name="spriteEffects">The sprite effect to apply on the sprite</param>
        /// <remarks>This function must be called between the <see cref="SpriteBatch.Begin(SiliconStudio.Xenko.Graphics.SpriteSortMode,SiliconStudio.Xenko.Graphics.Effect)"/> 
        /// and <see cref="SpriteBatch.End()"/> calls of the provided <paramref name="spriteBatch"/></remarks>
        /// <exception cref="ArgumentException">The provided frame index is not valid.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The provided spriteBatch is null</exception>
        public static void Draw(this Sprite sprite, SpriteBatch spriteBatch, Vector2 position, Color color, Vector2 scales, float rotation = 0f, float depthLayer = 0, SpriteEffects spriteEffects = SpriteEffects.None)
        {
            if (spriteBatch == null) throw new ArgumentNullException("spriteBatch");

            if (sprite.Texture == null)
                return;

            spriteBatch.Draw(sprite.Texture, position, sprite.Region, color, rotation, sprite.Center, scales, spriteEffects, sprite.Orientation, depthLayer);
        }