示例#1
0
        /// <summary>
        /// Takes a fractional offset from the top left of the box and will draw the
        /// box from the offset given.
        /// </summary>
        public void SetAnchorPoint(float offsetX, float offsetY)
        {
            //define an anchorpoint relative to the top left of the box between 0 and 1
            anchorPoint = new Vector2(offsetX * dimensions.X, offsetY * dimensions.Y);
            textBox.SetPosition(destinationPos);
            divisorA.SetPoints(
                new Vector2(destinationPos.X, textBox.DestinationRect.Bottom),
                new Vector2(destinationPos.X + width, textBox.DestinationRect.Bottom)
                );

            unitBoxes[0].SetPosition(new Vector2(destinationPos.X, textBox.DestinationRect.Bottom));
            for (int i = 1; i < unitBoxes.Length; i++)
            {
                unitBoxes[i].SetPosition(new Vector2(destinationPos.X, unitBoxes[i - 1].DestinationRect.Bottom));
            }
        }
示例#2
0
        /// <summary>
        /// Takes a fractional offset from the top left of the box and will draw the
        /// box from the offset given.
        /// </summary>
        public void SetAnchorPoint(float offsetX, float offsetY)
        {
            //define an anchorpoint relative to the top left of the box
            //expects between 0 and 1
            anchorPoint = new Vector2(offsetX * dimensions.X, offsetY * dimensions.Y);
            playerNameBox.SetPosition(destinationPos);

            //update the position of elements dependent on another elements position based on the new draw position.
            divisorA.SetPoints(
                new Vector2(destinationPos.X, playerNameBox.DestinationRect.Bottom),
                new Vector2(destinationPos.X + width, playerNameBox.DestinationRect.Bottom)
                );

            characterSpriteBox.SetPosition(new Vector2(destinationPos.X, playerNameBox.DestinationRect.Bottom));
            divisorB.SetPoints(
                new Vector2(destinationPos.X, characterSpriteBox.DestinationRect.Bottom),
                new Vector2(destinationPos.X + width, characterSpriteBox.DestinationRect.Bottom)
                );

            characterInfoBox.SetPosition(new Vector2(destinationPos.X, characterSpriteBox.DestinationRect.Bottom));
        }