Esempio n. 1
0
        internal void drawTexture(MonoGameTexture texture, float x, float y, int srcX, int srcY, int srcWidth,
                                  int srcHeight, float scaleX, float scaleY, float originX, float originY, float rotation, bool flipX,
                                  bool flipY, MonoGameColor tint)
        {
            beginRendering();
            if (texture.getUAddressMode() != _currentUMode || texture.getVAddressMode() != _currentVMode)
            {
                _currentUMode = texture.getUAddressMode();
                _currentVMode = texture.getVAddressMode();
                updateAddressMode();
            }


            _sharedPositionVector.X       = x - originX;
            _sharedPositionVector.Y       = y - originY;
            _sharedSourceRectangle.X      = srcX;
            _sharedSourceRectangle.Y      = srcY;
            _sharedSourceRectangle.Width  = srcWidth;
            _sharedSourceRectangle.Height = srcHeight;
            _sharedOriginVector.X         = originX;
            _sharedOriginVector.Y         = originY;
            _sharedScaleVector.X          = scaleX;
            _sharedScaleVector.Y          = scaleY;

            _spriteBatch.Draw(texture.texture2D, _sharedPositionVector, _sharedSourceRectangle, tint._color,
                              MonoGameMathsUtil.degreeToRadian(rotation), _sharedOriginVector, _sharedScaleVector,
                              (flipX ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (flipY ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
Esempio n. 2
0
        public void drawSprite(Sprite sprite, float x, float y)
        {
            beginRendering();
            if (sprite.getTexture().getUAddressMode() != _currentUMode || sprite.getTexture().getVAddressMode() != _currentVMode)
            {
                _currentUMode = sprite.getTexture().getUAddressMode();
                _currentVMode = sprite.getTexture().getVAddressMode();
                updateAddressMode();
            }

            _sharedPositionVector.X       = x + sprite.getOriginX();
            _sharedPositionVector.Y       = y + sprite.getOriginY();
            _sharedSourceRectangle.X      = sprite.getRegionX();
            _sharedSourceRectangle.Y      = sprite.getRegionY();
            _sharedSourceRectangle.Width  = sprite.getRegionWidth();
            _sharedSourceRectangle.Height = sprite.getRegionHeight();
            _sharedOriginVector.X         = sprite.getOriginX();
            _sharedOriginVector.Y         = sprite.getOriginY();
            _sharedScaleVector.X          = sprite.getScaleX();
            _sharedScaleVector.Y          = sprite.getScaleY();

            _spriteBatch.Draw(((MonoGameTexture)sprite.getTexture()).texture2D, _sharedPositionVector,
                              _sharedSourceRectangle, ((MonoGameColor)sprite.getTint())._color,
                              MonoGameMathsUtil.degreeToRadian(((MonoGameSprite)sprite).getTotalRotation()),
                              _sharedOriginVector, _sharedScaleVector, (sprite.isFlipX() ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (sprite.isFlipY() ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
Esempio n. 3
0
        public void drawTextureRegion(TextureRegion textureRegion, float x, float y, float width, float height, float rotation)
        {
            beginRendering();

            if (textureRegion.getTexture().getUAddressMode() != _currentUMode || textureRegion.getTexture().getVAddressMode() != _currentVMode)
            {
                _currentUMode = textureRegion.getTexture().getUAddressMode();
                _currentVMode = textureRegion.getTexture().getVAddressMode();
                updateAddressMode();
            }

            _sharedSourceRectangle.X      = textureRegion.getRegionX();
            _sharedSourceRectangle.Y      = textureRegion.getRegionY();
            _sharedSourceRectangle.Width  = textureRegion.getRegionWidth();
            _sharedSourceRectangle.Height = textureRegion.getRegionHeight();
            _sharedPositionVector.X       = x;
            _sharedPositionVector.Y       = y;
            _sharedScaleVector.X          = width / textureRegion.getRegionWidth();
            _sharedScaleVector.Y          = height / textureRegion.getRegionHeight();

            _spriteBatch.Draw(((MonoGameTexture)textureRegion.getTexture()).texture2D, _sharedPositionVector,
                              _sharedSourceRectangle, _tint, rotation, Vector2.Zero, _sharedScaleVector,
                              (textureRegion.isFlipX() ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (textureRegion.isFlipY() ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
Esempio n. 4
0
        public void drawTexture(Texture texture, float x, float y, float width, float height, bool flipY)
        {
            beginRendering();
            if (texture.getUAddressMode() != _currentUMode || texture.getVAddressMode() != _currentVMode)
            {
                _currentUMode = texture.getUAddressMode();
                _currentVMode = texture.getVAddressMode();
                updateAddressMode();
            }

            _sharedPositionVector.X = x;
            _sharedPositionVector.Y = y;
            _sharedScaleVector.X    = width / texture.getWidth();
            _sharedScaleVector.Y    = height / texture.getHeight();
            _spriteBatch.Draw(((MonoGameTexture)texture).texture2D, _sharedPositionVector, null, _tint, 0,
                              Vector2.Zero, _sharedScaleVector, flipY ? SpriteEffects.FlipVertically : SpriteEffects.None, 0f);
        }
Esempio n. 5
0
 public void setAddressMode(TextureAddressMode uMode, TextureAddressMode vMode)
 {
     _uMode = uMode;
     _vMode = vMode;
 }
Esempio n. 6
0
 public void setVAddressMode(TextureAddressMode mode)
 {
     _vMode = mode;
 }
Esempio n. 7
0
 public void setUAddressMode(TextureAddressMode mode)
 {
     _uMode = mode;
 }
 public static Microsoft.Xna.Framework.Graphics.TextureAddressMode convertTextureAddressMode(TextureAddressMode mode)
 {
     if (mode == TextureAddressMode.CLAMP_)
     {
         return(Microsoft.Xna.Framework.Graphics.TextureAddressMode.Clamp);
     }
     else if (mode == TextureAddressMode.MIRROR_)
     {
         return(Microsoft.Xna.Framework.Graphics.TextureAddressMode.Mirror);
     }
     else if (mode == TextureAddressMode.WRAP_)
     {
         return(Microsoft.Xna.Framework.Graphics.TextureAddressMode.Wrap);
     }
     else
     {
         throw new NotSupportedException();
     }
 }