Пример #1
0
        public void setRegion(int x, int y, int width, int height)
        {
            var invTexWidth  = 1f / _texture.getWidth();
            var invTexHeight = 1f / _texture.getHeight();

            setRegion(x * invTexWidth, y * invTexHeight, (x + width) * invTexWidth, (y + height) * invTexHeight);
            _regionWidth  = Math.Abs(width);
            _regionHeight = Math.Abs(height);
        }
Пример #2
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);
        }
Пример #3
0
 public void setRegion(Texture texture)
 {
     _texture = texture;
     setRegion(0, 0, texture.getWidth(), texture.getHeight());
 }
Пример #4
0
 public MonoGameTextureRegion(Texture texture)
 {
     _texture = texture ?? throw new java.lang.IllegalArgumentException();
     setRegion(0, 0, texture.getWidth(), texture.getHeight());
 }
Пример #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);
 }
Пример #6
0
 public void drawTexture(Texture texture, float x, float y, bool flipY)
 {
     drawTexture(texture, x, y, texture.getWidth(), texture.getHeight(), flipY);
 }
Пример #7
0
 public MonoGameSprite(Texture texture) : this(texture, texture.getWidth(), texture.getHeight())
 {
 }
Пример #8
0
 public void drawTexture(Texture texture, float x, float y, float width, float height, bool flipY)
 {
     _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);
 }