Beispiel #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Mdx.graphicsContext = new MonoGameGraphics(GraphicsDevice);
            Mdx.graphics        = new MonoGameGraphicsUtils(GraphicsDevice);
            Mdx.audio           = new MonoGameAudio();

            sampleTexture = Mdx.graphics.newTexture(Mdx.files.@internal("mini2Dx.png"));
            sampleRegion  = Mdx.graphics.newTextureRegion(sampleTexture);
            sampleRegion2 = Mdx.graphics.newTextureRegion(sampleTexture).split(16, 17)[1][1];
            sampleRegion2.flip(false, true);
            sampleSprite         = Mdx.graphics.newSprite(sampleTexture);
            sampleNinePatch      = Mdx.graphics.newNinePatch(Mdx.graphics.newTexture(Mdx.files.@internal("ninepatch.png")), 6, 6, 6, 6);
            sampleAtlas          = Mdx.graphics.newTextureAtlas(Mdx.files.@internal("pack.atlas"));
            sampleAtlasRegion    = sampleAtlas.findRegion("tileGreen", 47);
            sampleTilingDrawable = new MonoGameTilingDrawable(Mdx.graphics.newTexture(Mdx.files.@internal("background.png")));
            Mdx.graphicsContext.setColor(new MonoGameColor(255, 255, 255, 255));
            Mdx.graphicsContext.setBackgroundColor(new MonoGameColor(Color.Blue));
            sampleSprite.setOriginCenter();
            music = Mdx.audio.newMusic(Mdx.files.@internal("music.ogg"));
            sound = Mdx.audio.newSound(Mdx.files.@internal("sound.wav"));

            Mdx.audio.addMusicCompletionListener(new AudioCompletionListener());
            Mdx.audio.addSoundCompletionListener(new AudioCompletionListener());

            Mdx.input.newXbox360GamePad((GamePad)Mdx.input.getGamePads().get(0)).addListener(new UATInputProcessor(this));
        }
Beispiel #2
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);
 }
Beispiel #3
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);
        }
Beispiel #4
0
        public int add(Texture 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)
        {
            var operation = new SpriteCacheDrawingOperation
            {
                srcWidth  = srcWidth,
                srcHeight = srcHeight,
                dstX      = x,
                dstY      = y,
                scaleX    = scaleX,
                scaleY    = scaleY,
                originX   = originX,
                originY   = originY,
                rotation  = rotation,
                flipX     = flipX,
                flipY     = flipY,
                color     = _currentColor
            };

            add(texture, srcX, srcY, srcWidth, srcHeight, out operation.srcX, out operation.srcY);
            _caches[_currentCache].operations.Add(operation);
            return(_caches[_currentCache].operations.Count - 1);
        }
Beispiel #5
0
        private void add(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight, out int posX, out int posY)
        {
            if (_posX + srcWidth > _caches[_currentCache].texture.getWidth())
            {
                _posX      = 0;
                _posY     += _maxHeight;
                _maxHeight = 0;
            }

            _sharedSourceRectangle.X      = srcX;
            _sharedSourceRectangle.Y      = srcY;
            _sharedSourceRectangle.Width  = srcWidth;
            _sharedSourceRectangle.Height = srcHeight;
            _sharedPositionVector.X       = _posX;
            _sharedPositionVector.Y       = _posY;
            posX = _posX;
            posY = _posY;

            _spriteBatch.Draw(((MonoGameTexture)texture).texture2D, new Vector2(_posX, _posY),
                              new Rectangle(srcX, srcY, srcWidth, srcHeight), Microsoft.Xna.Framework.Color.White, 0f,
                              Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
            _posX     += srcWidth;
            _maxHeight = Math.Max(srcHeight, _maxHeight);
        }
Beispiel #6
0
 public Sprite newSprite(Texture texture, int x, int y, int width, int height)
 {
     return(new MonoGameSprite(texture, x, y, width, height));
 }
Beispiel #7
0
 public override TextureAtlasRegion newTextureAtlasRegion(Texture texture, string name, int index, int x, int y, int width, int height,
                                                          bool rotate, int originalWidth, int originalHeight, int offsetX, int offsetY)
 {
     return(new MonoGameTextureAtlasRegion(texture, name, index, x, y, width, height, rotate, originalWidth, originalHeight, offsetX, offsetY));
 }
 public MonoGameTextureRegion(Texture texture, int width, int height) : this(texture, 0, 0, width, height)
 {
 }
 public MonoGameTextureRegion(Texture texture, int x, int y, int width, int height)
 {
     _texture = texture ?? throw new java.lang.IllegalArgumentException();
     setRegion(x, y, width, height);
 }
 public void setTexture(Texture texture)
 {
     _texture = texture;
 }
 public void setRegion(TextureRegion region)
 {
     _texture = region.getTexture();
     setRegion(region.getU(), region.getV(), region.getU2(), region.getV2());
 }
Beispiel #12
0
 public NinePatch newNinePatch(Texture texture, int left, int right, int top, int bottom)
 {
     return(newNinePatch(new MonoGameTextureRegion(texture), left, right, top, bottom));
 }
Beispiel #13
0
 public int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight, float scaleX,
                float scaleY, bool flipX, bool flipY)
 {
     return(add(texture, x, y, 0, 0, texture.getWidth(), texture.getWidth(), 1, 1, 0, 0, 0, false, false));
 }
Beispiel #14
0
 public int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
 {
     return(add(texture, x, y, 0, 0, texture.getWidth(), texture.getWidth(), false, false));
 }
Beispiel #15
0
 public int add(Texture texture, float x, float y)
 {
     return(add(texture, x, y, 0, 0, texture.getWidth(), texture.getWidth()));
 }
Beispiel #16
0
 public override TextureRegion newTextureRegion(Texture texture, int width, int height)
 {
     return(new MonoGameTextureRegion(texture, width, height));
 }
Beispiel #17
0
 public override Sprite newSprite(Texture texture, int width, int height)
 {
     return(new MonoGameSprite(texture, width, height));
 }
Beispiel #18
0
 public TextureRegion newTextureRegion(Texture texture)
 {
     return(new MonoGameTextureRegion(texture));
 }
Beispiel #19
0
 public TextureRegion newTextureRegion(Texture texture, int x, int y, int width, int height)
 {
     return(new MonoGameTextureRegion(texture, x, y, width, height));
 }
Beispiel #20
0
 public void drawTexture(Texture texture, float x, float y)
 {
     drawTexture(texture, x, y, false);
 }
Beispiel #21
0
 public MonoGameSprite(Texture texture, int srcWidth, int srcHeight) : this(texture, 0, 0, srcWidth, srcHeight)
 {
 }
Beispiel #22
0
 public void drawTexture(Texture texture, float x, float y, bool flipY)
 {
     drawTexture(texture, x, y, texture.getWidth(), texture.getHeight(), flipY);
 }
 public void setRegion(TextureRegion region, int x, int y, int width, int height)
 {
     _texture = region.getTexture();
     setRegion(region.getRegionX() + x, region.getRegionY() + y, width, height);
 }
Beispiel #24
0
 public void drawTexture(Texture texture, float x, float y, float width, float height)
 {
     drawTexture(texture, x, y, width, height, false);
 }
 public MonoGameTextureRegion(Texture texture)
 {
     _texture = texture ?? throw new java.lang.IllegalArgumentException();
     setRegion(0, 0, texture.getWidth(), texture.getHeight());
 }
Beispiel #26
0
 public MonoGameSprite(Texture texture) : this(texture, texture.getWidth(), texture.getHeight())
 {
 }
 public MonoGameTextureRegion(Texture texture, float u, float v, float u2, float v2)
 {
     _texture = texture;
     setRegion(u, v, u2, v2);
 }
Beispiel #28
0
 public Sprite newSprite(Texture texture)
 {
     return(new MonoGameSprite(texture));
 }
 public void setRegion(Texture texture)
 {
     _texture = texture;
     setRegion(0, 0, texture.getWidth(), texture.getHeight());
 }
Beispiel #30
0
 public MonoGameSprite(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) : base(texture, srcX,
                                                                                                srcY, srcWidth, srcHeight)
 {
     setBounds(srcX, srcY, srcWidth, srcHeight);
     setOriginCenter();
 }