public static ConvertVector3 ( Sharpex2D.Math.Vector2 position ) : Vector3? | ||
position | Sharpex2D.Math.Vector2 | The Vector2. |
Résultat | Vector3? |
/// <summary> /// Draws a Texture. /// </summary> /// <param name="spriteSheet">The SpriteSheet.</param> /// <param name="position">The Position.</param> /// <param name="color">The Color.</param> /// <param name="opacity">The Opacity.</param> public void DrawTexture(SpriteSheet spriteSheet, Vector2 position, Color color, float opacity = 1) { var dxTexture = spriteSheet.Texture2D as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX9 expects a DirectXTexture as resource."); } _sprite.Draw(dxTexture.GetTexture(), DirectXHelper.ConvertToWinRectangle(spriteSheet.Rectangle), null, DirectXHelper.ConvertVector3(position), DirectXHelper.ConvertColor(color)); }
/// <summary> /// Draws a Texture. /// </summary> /// <param name="spriteSheet">The SpriteSheet.</param> /// <param name="rectangle">The Rectangle.</param> /// <param name="color">The Color.</param> /// <param name="opacity">The Opacity.</param> public void DrawTexture(SpriteSheet spriteSheet, Rectangle rectangle, Color color, float opacity = 1) { var dxTexture = spriteSheet.Texture2D as DirectXTexture; if (dxTexture == null) { throw new ArgumentException("DirectX9 expects a DirectXTexture as resource."); } //calc percentages for scaling float scaleX = rectangle.Width / spriteSheet.Rectangle.Width; float scaleY = rectangle.Height / spriteSheet.Rectangle.Height; _sprite.Transform = Matrix.Scaling(scaleX, scaleY, 1f); _sprite.Draw(dxTexture.GetTexture(), DirectXHelper.ConvertToWinRectangle(spriteSheet.Rectangle), null, DirectXHelper.ConvertVector3(new Vector2(rectangle.X / scaleX, rectangle.Y / scaleY)), DirectXHelper.ConvertColor(color)); _sprite.Transform = Matrix.Identity; }