Exemplo 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);
        }
Exemplo n.º 2
0
        public void drawTextureRegion(TextureRegion textureRegion, float x, float y, float width, float height, float rotation)
        {
            if (textureRegion.getTexture().getUAddressMode() != _currentUMode || textureRegion.getTexture().getVAddressMode() != _currentVMode)
            {
                _currentUMode = textureRegion.getTexture().getUAddressMode();
                _currentVMode = textureRegion.getTexture().getVAddressMode();
                updateAddressMode();
            }
            var sourceRectangle = new Rectangle(textureRegion.getRegionX(), textureRegion.getRegionY(), textureRegion.getRegionWidth(), textureRegion.getRegionHeight());

            if (textureRegion.isFlipX())
            {
                sourceRectangle.X -= sourceRectangle.Width;
            }

            if (textureRegion.isFlipY())
            {
                sourceRectangle.Y -= sourceRectangle.Height;
            }
            _spriteBatch.Draw(((MonoGameTexture)textureRegion.getTexture()).texture2D,
                              (new Vector2(x, y) + _translation - _rotationCenter) * _scale, sourceRectangle, _tint, rotation, Vector2.Zero,
                              new Vector2(width / textureRegion.getRegionWidth(), height / textureRegion.getRegionHeight()) *
                              _scale, (textureRegion.isFlipX() ? SpriteEffects.FlipHorizontally : SpriteEffects.None) |
                              (textureRegion.isFlipY() ? SpriteEffects.FlipVertically : SpriteEffects.None), 0f);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
 public void drawTexture(Texture texture, float x, float y, float width, float height, bool flipY)
 {
     if (texture.getUAddressMode() != _currentUMode || texture.getVAddressMode() != _currentVMode)
     {
         _currentUMode = texture.getUAddressMode();
         _currentVMode = texture.getVAddressMode();
         updateAddressMode();
     }
     _spriteBatch.Draw(((MonoGameTexture)texture).texture2D, (new Vector2(x, y) + _translation - _rotationCenter) * _scale, null, _tint, 0,
                       Vector2.Zero, new Vector2(width / texture.getWidth(), height / texture.getHeight()) * _scale,
                       flipY ? SpriteEffects.FlipVertically : SpriteEffects.None, 0f);
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 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();
     }
 }
Exemplo n.º 8
0
 public void setAddressMode(TextureAddressMode uMode, TextureAddressMode vMode)
 {
     _uMode = uMode;
     _vMode = vMode;
 }
Exemplo n.º 9
0
 public void setVAddressMode(TextureAddressMode mode)
 {
     _vMode = mode;
 }
Exemplo n.º 10
0
 public void setUAddressMode(TextureAddressMode mode)
 {
     _uMode = mode;
 }