ConvertVector2() 공개 정적인 메소드

Converts the Vector2 into DXVector3.
public static ConvertVector2 ( Sharpex2D.Math.Vector2 vector2 ) : Vector3
vector2 Sharpex2D.Math.Vector2 The Vector2.
리턴 Vector3
예제 #1
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="position">The Position.</param>
        /// <param name="opacity">The Opacity.</param>
        /// <param name="color">The Color.</param>
        public void DrawTexture(Texture2D texture, Vector2 position, Color color, float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX9 expects a DirectXTexture as resource.");
            }

            _sprite.Draw(dxTexture.GetTexture(), null, DirectXHelper.ConvertVector2(position),
                         DirectXHelper.ConvertColor(color));
        }
예제 #2
0
        /// <summary>
        /// Draws a Texture.
        /// </summary>
        /// <param name="texture">The Texture.</param>
        /// <param name="rectangle">The Rectangle.</param>
        /// <param name="opacity">The Opacity.</param>
        /// <param name="color">The Color.</param>
        public void DrawTexture(Texture2D texture, Rectangle rectangle, Color color, float opacity = 1)
        {
            var dxTexture = texture as DirectXTexture;

            if (dxTexture == null)
            {
                throw new ArgumentException("DirectX9 expects a DirectXTexture as resource.");
            }

            //calc percentages for scaling

            float scaleX = rectangle.Width / texture.Width;
            float scaleY = rectangle.Height / texture.Height;

            _sprite.Transform = Matrix.Scaling(scaleX, scaleY, 1f);

            _sprite.Draw(dxTexture.GetTexture(), null,
                         DirectXHelper.ConvertVector2(new Vector2(rectangle.X / scaleX, rectangle.Y / scaleY)),
                         DirectXHelper.ConvertColor(color));

            _sprite.Transform = Matrix.Identity;
        }