Ejemplo n.º 1
0
        public void CD_RectsDontCollide()
        {
            var a = RectangleX.FromLTRB(0, 0, 10, 10).ToPolygon();
            var b = RectangleX.FromLTRB(8, 11, 20, 20).ToPolygon();

            collider.DoPolygonsIntersect(a, b).Should().BeFalse();
        }
Ejemplo n.º 2
0
        private void parseAtlasXml(XmlDocument atlasXml)
        {
            float scale = Convert.ToSingle(atlasXml.Attributes["scale"]);

            XmlNodeList nodeList = atlasXml.SelectNodes("SubTExture");

            foreach (XmlNode subTexture in nodeList)
            {
                string name = cleanMasterString(subTexture.Attributes["name"].Value);
                float  x    = Convert.ToSingle(subTexture.Attributes["x"].Value) / scale;
                float  y    = Convert.ToSingle(subTexture.Attributes["y"].Value) / scale;

                float width       = Convert.ToSingle(subTexture.Attributes["width"].Value) / scale;
                float height      = Convert.ToSingle(subTexture.Attributes["height"].Value) / scale;
                float frameX      = Convert.ToSingle(subTexture.Attributes["frameX"].Value) / scale;
                float frameY      = Convert.ToSingle(subTexture.Attributes["frameY"].Value) / scale;
                float frameWidth  = Convert.ToSingle(subTexture.Attributes["frameWidth"].Value) / scale;
                float frameHeight = Convert.ToSingle(subTexture.Attributes["frameHeight"].Value) / scale;
                bool  rotated     = Convert.ToBoolean(subTexture.Attributes["rotated"].Value);


                RectangleX region = new RectangleX(x, y, width, height);
                RectangleX frame  = frameWidth > 0 && frameHeight > 0
                    ? new RectangleX(frameX, frameY, frameWidth, frameHeight)
                    : null;

                addRegion(name, region, frame, rotated);
            }
        }
Ejemplo n.º 3
0
        public Scroller(Direction direction)
        {
            name = "Scroller";

            horizontalBar = new Bar(Direction.HORIZONTAL);
            verticalBar   = new Bar(Direction.VERTICAL);

            if (direction == Direction.HORIZONTAL)
            {
                _horizontalEnabled = true;
                draggingDistanceX  = 10;
            }
            else
            {
                _verticalEnabled  = true;
                draggingDistanceY = 10;
            }

            horizontalBar.alpha = 0;
            verticalBar.alpha   = 0;

            base.addChild(horizontalBar);
            base.addChild(verticalBar);

            _scrollRect = new RectangleX(0, 0, 1, 1);

            touchable = true;
        }
Ejemplo n.º 4
0
        public void CD_RectsCollide()
        {
            var a = RectangleX.FromLTRB(0, 0, 10, 10).ToPolygon();
            var b = RectangleX.FromLTRB(9, 9, 20, 20).ToPolygon();

            collider.DoPolygonsIntersect(a, b).Should().BeTrue();
        }
Ejemplo n.º 5
0
        public void CD_SharedCornerDoesntCollide()
        {
            var a = RectangleX.FromLTRB(0, 0, 10, 10).ToPolygon();
            var b = RectangleX.FromLTRB(10, 10, 20, 20).ToPolygon();

            collider.DoPolygonsIntersect(a, b).Should().BeFalse();
        }
Ejemplo n.º 6
0
 public void addRegion(string name, RectangleX region, RectangleX frame = null, bool rotated = false)
 {
     if (mTextureInfos.ContainsKey(name))
     {
         return;
     }
     mTextureInfos.Add(name, new TextureInfo(region, frame, rotated));
 }
Ejemplo n.º 7
0
        public void FromStringDelimited()
        {
            var rect = RectangleX.Parse("2, 3, 4, 5");

            rect.X.Should().Be(2);
            rect.Y.Should().Be(3);
            rect.Width.Should().Be(4);
            rect.Height.Should().Be(5);
        }
Ejemplo n.º 8
0
        public void Rect_MultiUnion()
        {
            var result = RectangleX.Union(
                new Rectangle(1, 2, 3, 4),
                new Rectangle(5, 6, 7, 8),
                new Rectangle(9, 10, 11, 12),
                new Rectangle(2, 2, 2, 2));

            result.Should().Be(new Rectangle(1, 2, 19, 20));
        }
Ejemplo n.º 9
0
        public Image(TextureX texture)
        {
            _texture = texture;

            RectangleX frame  = _texture.frame;
            float      width  = frame != null ? frame.width : texture.width;
            float      height = frame != null ? frame.height : texture.height;

            this.init(width, height);
        }
Ejemplo n.º 10
0
        public void readjustSize()
        {
            RectangleX frame = _texture.frame;
            float      w     = frame != null ? frame.width : texture.width;
            float      h     = frame != null ? frame.height : texture.height;

            vertices[0] = new Vector3X(0, 0);
            vertices[1] = new Vector3X(w, 0);
            vertices[2] = new Vector3X(w, h);
            vertices[3] = new Vector3X(0, h);
        }
Ejemplo n.º 11
0
        public void Poly_Rotate()
        {
            var a = RectangleX.FromLTRB(0, 0, 10, 5).ToPolygon();
            var b = a.RotateDegrees(90, new Vector2(10, 5));

            b.Count.Should().Be(4);

            b.Any(x => Vector2X.Equals(x, new Vector2(5, 5), 1e-5f)).Should().BeTrue();
            b.Any(x => Vector2X.Equals(x, new Vector2(10, 5), 1e-5f)).Should().BeTrue();
            b.Any(x => Vector2X.Equals(x, new Vector2(10, 15), 1e-5f)).Should().BeTrue();
            b.Any(x => Vector2X.Equals(x, new Vector2(5, 15), 1e-5f)).Should().BeTrue();
        }
Ejemplo n.º 12
0
        public override RectangleX getBounds(DisplayObjectX targetSpace)
        {
            RectangleX resultRect = new RectangleX();


            int numChildren = mChildren.Count;

            if (numChildren == 0)
            {
                getTransformationMatrix(targetSpace, sHelperTransform);
                //todo;
                resultRect.setTo(0, 0, 0, 0);
            }
            else if (numChildren == 1)
            {
                resultRect = mChildren[0].getBounds(targetSpace);
            }
            else
            {
                float minX = float.MaxValue;
                float maxX = -float.MaxValue;
                float minY = float.MinValue;
                float maxY = -float.MinValue;

                for (int i = 0; i < numChildren; ++i)
                {
                    resultRect = mChildren[i].getBounds(targetSpace);

                    if (minX > resultRect.x)
                    {
                        minX = resultRect.x;
                    }
                    if (maxX < resultRect.width)
                    {
                        maxX = resultRect.width;
                    }
                    if (minY > resultRect.y)
                    {
                        minY = resultRect.y;
                    }
                    if (maxY < resultRect.height)
                    {
                        maxY = resultRect.height;
                    }
                }

                resultRect.setTo(minX, minY, maxX - minX, maxY - minY);
            }

            return(resultRect);
        }
Ejemplo n.º 13
0
        public Scale9Image(TextureX texture, RectangleX centerRect)
        {
            _tW   = texture.width;
            _tH   = texture.height;
            _grid = centerRect;

            _width  = _tW;
            _height = _tH;

            _tl = new Image(TextureX.fromTexture(texture, new RectangleX(0, 0, _grid.x, _grid.y)));

            _tc = new Image(TextureX.fromTexture(texture, new RectangleX(_grid.x, 0, _grid.width, _grid.y)));

            _tr = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, 0, texture.width - (_grid.x + _grid.width), _grid.y)));

            _cl = new Image(TextureX.fromTexture(texture, new RectangleX(0, _grid.y, _grid.x, _grid.height)));

            _cc = new Image(TextureX.fromTexture(texture, new RectangleX(_grid.x, _grid.y, _grid.width, _grid.height)));

            _cr = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, _grid.y, texture.width - (_grid.x + _grid.width), _grid.height)));

            _bl = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(0, _grid.y + _grid.height, _grid.x, texture.height - (_grid.y + _grid.height))));

            _bc = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x, _grid.y + _grid.height, _grid.width,
                                                                texture.height - (_grid.y + _grid.height))));

            _br = new Image(TextureX.fromTexture(texture,
                                                 new RectangleX(_grid.x + _grid.width, _grid.y + _grid.height,
                                                                texture.width - (_grid.x + _grid.width), texture.height - (_grid.y + _grid.height))));

            _tc.x = _cc.x = _bc.x = _grid.x;
            _cl.y = _cc.y = _cr.y = _grid.y;

            addChild(_tl);
            addChild(_tc);
            addChild(_tr);

            addChild(_cl);
            addChild(_cc);
            addChild(_cr);

            addChild(_bl);
            addChild(_bc);
            addChild(_br);

            apply9Scale(_tW, _tH);
        }
Ejemplo n.º 14
0
        private void DrawImageFrame(BorderStyle border, Rectangle borderRect, Rectangle?maybeSrcRect)
        {
            var image = imageProvider.Load <Texture2D>(border.Image.File);

            var       slice     = border.ImageSlice;
            Rectangle outerRect = maybeSrcRect ?? new Rectangle(0, 0, image.Width, image.Height);
            Rectangle innerRect = RectangleX.FromLTRB(
                outerRect.Left + slice.Left,
                outerRect.Top + slice.Top,
                outerRect.Right - slice.Right,
                outerRect.Bottom - slice.Bottom);

            DrawFrame(SpriteBatch, borderRect, image, innerRect, outerRect, border.ImageScale);
        }
Ejemplo n.º 15
0
        private void ColorOrcs()
        {
            if (Story.DefeatedOrcs == false)
            {
                Rectangle area = RectangleX.FromLTRB(66, 0, TheMap.Width, 68);

                foreach (var guard in TheMap.Guards)
                {
                    if (area.Contains(guard.Location))
                    {
                        guard.Color = XleColor.Blue;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Creates a new instance of ShootTraps
        /// </summary>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public ShootTraps(int width, int height, IContentProvider content)
        {
            if (width <= 0 || height <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            gunImage = content.Load <Texture2D>("barrel");
            gunBolt  = content.Load <Texture2D>("barrel-hex");

            mGameObjects = new List <GameObject>();
            mRandom      = new Random();

            mGroundY = height - 10;

            // choose a y velocity (pixels / second) that will get the
            // traps nearly to the top of the screen
            mTrapVYScale = (int)Math.Sqrt(2 * GameObject.Gravity * (height - 10));

            double timeInAir = mTrapVYScale * 2 / GameObject.Gravity;

            // choose a minimum x velocity so that the trap will make it at least 1/3
            // the way across the field.
            mTrapMaxVX = mTrapVYScale / 2;
            mTrapMinVX = (int)(width / (3.0 * timeInAir));

            gunPosition = new Vector2(width / 2, mGroundY);

            mLaunchX = new int[4];

            // area of screen where traps are launched from.
            int launchScale = width / 2 - 50;

            mLaunchX[0] = width / 2 - launchScale;
            mLaunchX[1] = width / 2 - launchScale + 40;

            mLaunchX[2] = width - mLaunchX[1];
            mLaunchX[3] = width - mLaunchX[0];

            GameObject.FieldArea = RectangleX.FromLTRB(-10, -20, width + 10, (int)gunPosition.Y);

            Bullet.Image = content.Load <Texture2D>("bullet");
            Trap.Image   = content.Load <Texture2D>("enemy");
            Particle.Images.Add(content.Load <Texture2D>("splatter-1"));
            Particle.Images.Add(content.Load <Texture2D>("splatter-2"));
            Particle.Images.Add(content.Load <Texture2D>("splatter-3"));
            Particle.Images.Add(content.Load <Texture2D>("splatter-4"));
        }
Ejemplo n.º 17
0
        public void CD_ConcavePolygonsDontCollide()
        {
            var a = new Polygon
            {
                { 0, 0 },
                { 5, 0 },
                { 5, 4 },
                { 4, 4 },
                { 4, 1 },
                { 1, 1 },
                { 1, 4 },
                { 0, 4 },
            };

            var b = RectangleX.FromLTRB(2, 2, 3, 3).ToPolygon();

            collider.DoPolygonsIntersect(a, b).Should().BeFalse();
        }
Ejemplo n.º 18
0
        public SubTextureX(TextureX parentTexture, RectangleX region, RectangleX frame = null)
        {
            if (region == null)
            {
                region = new RectangleX(0, 0, parentTexture.width, parentTexture.height);
            }

            mParent = parentTexture;
            mFrame  = frame != null?frame.clone() : null;

            mWidth  = region.width;
            mHeight = region.height;


            mTransform = new Transform2X();

            mTransform.scale(region.width / mParent.width,
                             region.height / mParent.height);
            mTransform.translate(region.x / mParent.width,
                                 -1 - region.y / mParent.height);
        }
Ejemplo n.º 19
0
        private void onTouch(RectangleX e)
        {
            //Mouse.cursor = (mUseHandCursor && mEnabled && event.interactsWith(this)) ?
            //    MouseCursor.BUTTON : MouseCursor.AUTO;

            //MouseEvent mouseEvent = e as MouseEvent;

            //Touch touch = e.getTouch(this);
            //Touch touch = mouseEvent.touch;

            /*if (!mEnabled || touch == null) return;
             *
             * if (touch.phase == TouchPhase.Began && !mIsDown)
             * {
             *  //mBackground.texture = mDownState;
             *  mContents.scaleX = mContents.scaleY = mScaleWhenDown;
             *  mContents.x = (1.0f - mScaleWhenDown) / 2.0f * mBackground.width;
             *  mContents.y = (1.0f - mScaleWhenDown) / 2.0f * mBackground.height;
             *  mIsDown = true;
             * }
             * else if (touch.phase == TouchPhase.Moved && mIsDown)
             * {
             *  // reset button when user dragged too far away after pushing
             *  Rectangle buttonRect = getBounds(stage);
             *  if (touch.position.x < buttonRect.x - MAX_DRAG_DIST ||
             *      touch.position.y < buttonRect.y - MAX_DRAG_DIST ||
             *      touch.position.x > buttonRect.x + buttonRect.width + MAX_DRAG_DIST ||
             *      touch.position.y > buttonRect.y + buttonRect.height + MAX_DRAG_DIST)
             *  {
             *      resetContents();
             *  }
             * }
             * else if (touch.phase == TouchPhase.Ended && mIsDown)
             * {
             *  resetContents();
             *  //dispatchEventWith(Event.TRIGGERED, true);
             * }*/
        }
Ejemplo n.º 20
0
        public Button(DisplayObjectX upState, string text = "", DisplayObjectX downState = null, TextFormat format = null)
        {
            //if (upState == null) throw new ErrorEvent("Texture cannot be null");

            mParent     = upState.parent;
            mUpState    = upState;
            mDownState  = downState != null ? downState : upState;
            mBackground = upState;
            mTextFormat = format;

            mScaleWhenDown     = 0.9f;
            mAlphaWhenDisabled = 0.5f;
            mEnabled           = true;
            mIsDown            = false;
            mUseHandCursor     = true;
            mTextBounds        = new RectangleX(0, 0, upState.width, upState.height);

            mContents = new DisplayObjectContainerX();
            mContents.addChild(mBackground);
            addChild(mContents);

            //addEventListener(TouchEvent.TOUCH, onTouch);
            addEventListener(MouseEventX.MOUSE_DOWN, onMouseDown);

            if (text.Length > 0)
            {
                this.text = text;
            }

            this.x    = upState.x;
            this.y    = upState.y;
            upState.x = upState.y = 0;

            if (mParent != null)
            {
                mParent.addChild(this);
            }
        }
Ejemplo n.º 21
0
        private void DrawClipped(Texture2D image, Point dest, Rectangle clipRect, Rectangle?maybeSrcRect)
        {
            Rectangle srcRect  = maybeSrcRect ?? new Rectangle(0, 0, image.Width, image.Height);
            Rectangle destRect = new Rectangle(dest.X, dest.Y, srcRect.Width, srcRect.Height);

            if (clipRect.Contains(destRect) == false)
            {
                int lc = 0, tc = 0, rc = 0, bc = 0;

                if (destRect.Left < clipRect.Left)
                {
                    lc = clipRect.Left - destRect.Left;
                }
                if (destRect.Top < clipRect.Top)
                {
                    tc = clipRect.Top - destRect.Top;
                }
                if (destRect.Right > clipRect.Right)
                {
                    rc = clipRect.Right - destRect.Right;
                }
                if (destRect.Bottom > clipRect.Bottom)
                {
                    bc = clipRect.Bottom - destRect.Bottom;
                }

                destRect = RectangleX.FromLTRB(destRect.Left + lc, destRect.Top + tc, destRect.Right + rc, destRect.Bottom + bc);
                srcRect  = RectangleX.FromLTRB(srcRect.Left + lc, srcRect.Top + tc, srcRect.Right + rc, srcRect.Bottom + bc);

                if (destRect.Width == 0 || destRect.Height == 0)
                {
                    return;
                }
            }

            SpriteBatch.Draw(image, destRect, srcRect, Color.White);
        }
Ejemplo n.º 22
0
 public TextureInfo(RectangleX region, RectangleX frame, bool rotated)
 {
     this.region  = region;
     this.frame   = frame;
     this.rotated = rotated;
 }
Ejemplo n.º 23
0
        public override RectangleX getBounds(DisplayObjectX targetSpace)
        {
            RectangleX resultRect = new RectangleX();

            if (targetSpace == this) // optimization
            {
                resultRect.setTo(0.0f, 0.0f, vertices[2].x, vertices[2].y);
            }
            else if (targetSpace == parent && rotation == 0.0) // optimization
            {
                float    scaleX = this.scaleX;
                float    scaleY = this.scaleY;
                Vector3X v      = vertices[2];

                resultRect.setTo(x - pivotX * scaleX, y - pivotY * scaleY, v.x * scaleX, v.y * scaleY);
                if (scaleX < 0)
                {
                    resultRect.width *= -1;
                    resultRect.x     -= resultRect.width;
                }
                if (scaleY < 0)
                {
                    resultRect.height *= -1;
                    resultRect.y      -= resultRect.height;
                }
            }
            else
            {
                getTransformationMatrix(targetSpace, sHelperTransform);

                float minX = float.MaxValue;
                float maxX = -float.MaxValue;
                float minY = float.MinValue;
                float maxY = -float.MinValue;

                int len = vertices.Length;
                for (int i = 0; i < len; i++)
                {
                    Vector3X v = sHelperTransform.transformVector(vertices[i]);

                    if (minX > v.x)
                    {
                        minX = v.x;
                    }
                    if (maxX < v.x)
                    {
                        maxX = v.x;
                    }
                    if (minY > v.y)
                    {
                        minY = v.y;
                    }
                    if (maxY < v.y)
                    {
                        maxY = v.y;
                    }
                }

                resultRect.setTo(minX, minY, maxX - minX, maxY - minY);
            }

            return(resultRect);
        }
Ejemplo n.º 24
0
 public void textBounds(RectangleX value)
 {
     createTextField();
     mTextBounds = value.clone();
 }
Ejemplo n.º 25
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (GameState == null)
            {
                return;
            }

            DrawTextAreaBackColor(spriteBatch, GameState.Map.ColorScheme);

            Player player = GameState.Player;
            XleMap map    = GameState.Map;

            int   i          = 0;
            Color boxColor   = map.ColorScheme.FrameColor;
            Color innerColor = map.ColorScheme.FrameHighlightColor;
            int   horizLine  = 18 * 16;
            int   vertLine   = (38 - map.ColorScheme.MapAreaWidth) * 16;

            Screen.FontColor = map.ColorScheme.TextColor;
            Color menuColor = map.ColorScheme.TextColor;

            if (commands.IsLeftMenuActive)
            {
                menuColor = XleColor.Yellow;
            }

            DrawFrame(spriteBatch, boxColor);

            DrawFrameLine(spriteBatch, vertLine, 0, 0, horizLine + 12, boxColor);
            DrawFrameLine(spriteBatch, 0, horizLine, 1, GameAreaSize.Width, boxColor);

            DrawFrameHighlight(spriteBatch, innerColor);

            DrawInnerFrameHighlight(spriteBatch, vertLine, 0, 0, horizLine + 12, innerColor);
            DrawInnerFrameHighlight(spriteBatch, 0, horizLine, 1, GameAreaSize.Width, innerColor);

            Rectangle mapRect = RectangleX.FromLTRB
                                    (vertLine + 16, 16, GameAreaSize.Width - 16, horizLine);

            MapRenderer.Draw(spriteBatch, player.Location, player.FaceDirection, mapRect);

            i = 0;
            int cursorPos = 0;

            foreach (var cmd in commands.Items.ToList())
            {
                WriteText(spriteBatch, 48, 16 * (i + 1), cmd.Name, menuColor);

                if (cmd == commands.CurrentCommand)
                {
                    cursorPos = i;
                }

                i++;
            }

            WriteText(spriteBatch, 32, 16 * (cursorPos + 1), "`", menuColor);

            Color hpColor = statsDisplay.HPColor;

            WriteText(spriteBatch, 48, 16 * 15, "H.P. " + statsDisplay.HP, hpColor);
            WriteText(spriteBatch, 48, 16 * 16, "Food " + statsDisplay.Food, hpColor);
            WriteText(spriteBatch, 48, 16 * 17, "Gold " + statsDisplay.Gold, hpColor);

            TextAreaRenderer.Draw(spriteBatch, TextArea);

            if (map.AutoDrawPlayer)
            {
                DrawRafts(spriteBatch, mapRect);

                if (player.IsOnRaft == false)
                {
                    DrawCharacter(spriteBatch, playerAnimator.Animating, playerAnimator.AnimFrame, vertLine);
                }
            }

            if (Screen.PromptToContinue)
            {
                FillRect(spriteBatch, 192, 384, 17 * 16, 16, XleColor.Black);
                WriteText(spriteBatch, 208, 384, "(Press to Cont)", XleColor.Yellow);
            }
        }
Ejemplo n.º 26
0
        public void DrawFrame(SpriteBatch spriteBatch, Rectangle destOuterRect, Texture2D frameTexture,
                              Rectangle frameSourceInner, Rectangle frameSourceOuter,
                              ImageScale borderScale)
        {
            this.SpriteBatch = spriteBatch;

            Rectangle destInnerRect = destOuterRect;
            Size      delta         = new Size(frameSourceInner.X - frameSourceOuter.X, frameSourceInner.Y - frameSourceOuter.Y);

            destInnerRect.X      += delta.Width;
            destInnerRect.Y      += delta.Height;
            destInnerRect.Width  -= (delta.Width) * 2;
            destInnerRect.Height -= (delta.Height) * 2;

            Rectangle src, dest;
            Rectangle outer = frameSourceOuter, inner = frameSourceInner;

            // top left
            src  = RectangleX.FromLTRB(outer.Left, outer.Top, inner.Left, inner.Top);
            dest = RectangleX.FromLTRB(destOuterRect.Left, destOuterRect.Top, destInnerRect.Left, destInnerRect.Top);

            SpriteBatch.Draw(frameTexture, dest, src, Color.White);

            // top
            src  = RectangleX.FromLTRB(inner.Left, outer.Top, inner.Right, inner.Top);
            dest = RectangleX.FromLTRB(destInnerRect.Left, destOuterRect.Top, destInnerRect.Right, destInnerRect.Top);

            ScaleSurface(frameTexture, src, dest, borderScale);

            // top right
            src  = RectangleX.FromLTRB(inner.Right, outer.Top, outer.Right, inner.Top);
            dest = RectangleX.FromLTRB(destInnerRect.Right, destOuterRect.Top, destOuterRect.Right, destInnerRect.Top);

            SpriteBatch.Draw(frameTexture, dest, src, Color.White);

            // left
            src  = RectangleX.FromLTRB(outer.Left, inner.Top, inner.Left, inner.Bottom);
            dest = RectangleX.FromLTRB(destOuterRect.Left, destInnerRect.Top, destInnerRect.Left, destInnerRect.Bottom);

            ScaleSurface(frameTexture, src, dest, borderScale);

            // right
            src  = RectangleX.FromLTRB(inner.Right, inner.Top, outer.Right, inner.Bottom);
            dest = RectangleX.FromLTRB(destInnerRect.Right, destInnerRect.Top, destOuterRect.Right, destInnerRect.Bottom);

            ScaleSurface(frameTexture, src, dest, borderScale);

            // bottom left
            src  = RectangleX.FromLTRB(outer.Left, inner.Bottom, inner.Left, outer.Bottom);
            dest = RectangleX.FromLTRB(destOuterRect.Left, destInnerRect.Bottom, destInnerRect.Left, destOuterRect.Bottom);

            SpriteBatch.Draw(frameTexture, dest, src, Color.White);

            // bottom
            src  = RectangleX.FromLTRB(inner.Left, inner.Bottom, inner.Right, outer.Bottom);
            dest = RectangleX.FromLTRB(destInnerRect.Left, destInnerRect.Bottom, destInnerRect.Right, destOuterRect.Bottom);

            ScaleSurface(frameTexture, src, dest, borderScale);

            // bottom right
            src  = RectangleX.FromLTRB(inner.Right, inner.Bottom, outer.Right, outer.Bottom);
            dest = RectangleX.FromLTRB(destInnerRect.Right, destInnerRect.Bottom, destOuterRect.Right, destOuterRect.Bottom);

            SpriteBatch.Draw(frameTexture, dest, src, Color.White);
        }
Ejemplo n.º 27
0
 public static TextureX fromTexture(TextureX texture, RectangleX region = null, RectangleX frame = null)
 {
     return(new SubTextureX(texture, region, frame));
 }