public Vector2 AbsolutePosition() { Viewport viewport = Engine.Core.Instance.GetViewport(); float x = 0; float y = 0; float relativePositionX = RelativePosition.X * Engine.Content.DEFAULT_SCALE; float relativePositionY = RelativePosition.Y * Engine.Content.DEFAULT_SCALE; float width = Width * Engine.Content.DEFAULT_SCALE; float height = Height * Engine.Content.DEFAULT_SCALE; float parentWidth = viewport.Width; float parentHeight = viewport.Height; if (Parent != null) { Vector2 absolutePosition = Parent.AbsolutePosition(); x = absolutePosition.X; y = absolutePosition.Y; parentWidth = Parent.Width * Engine.Content.DEFAULT_SCALE; parentHeight = Parent.Height * Engine.Content.DEFAULT_SCALE; } switch (ParentAnchor) { case Anchor.TopLeft: x += relativePositionX; y += relativePositionY; break; case Anchor.TopRight: x += parentWidth - relativePositionX - width; y += relativePositionY; break; case Anchor.BottomLeft: x += relativePositionX; y += parentHeight - relativePositionY - height; break; case Anchor.BottomRight: x += parentWidth - relativePositionX - width; y += parentHeight - relativePositionY - height; break; case Anchor.Center: x += (parentWidth - width) / 2 - relativePositionX; y += (parentHeight - height) / 2 - relativePositionY; break; } return(new Vector2(x, y)); }