예제 #1
0
 public static Vector2 GetTopLeftPosition(Size shape, Vector2 anchoredPosition, RectAnchors anchor)
 {
     switch (anchor)
     {
         case RectAnchors.Top:
             return anchoredPosition - new Vector2(shape.Width / 2, 0);
         case RectAnchors.TopRight:
             return anchoredPosition - new Vector2(shape.Width, 0);
         case RectAnchors.Left:
             return anchoredPosition - new Vector2(0, shape.Height / 2);
         case RectAnchors.Center:
             return anchoredPosition - new Vector2(shape.Width / 2, shape.Height / 2);
         case RectAnchors.Right:
             return anchoredPosition - new Vector2(shape.Width, shape.Height / 2);
         case RectAnchors.BottomLeft:
             return anchoredPosition - new Vector2(0, shape.Height);
         case RectAnchors.Bottom:
             return anchoredPosition - new Vector2(shape.Width / 2, shape.Height);
         case RectAnchors.BottomRight:
             return anchoredPosition - new Vector2(shape.Width, shape.Height);
         default:
             return anchoredPosition;
     }
 }
예제 #2
0
파일: Camera.cs 프로젝트: ezamagni/xebab
 public void SetViewportPosition(Vector2 position, RectAnchors anchor)
 {
     this.viewport.Position = AnchorHelper.GetTopLeftPosition(Size, position, anchor);
 }
예제 #3
0
파일: Camera.cs 프로젝트: ezamagni/xebab
 public Vector2 GetViewportPosition(RectAnchors anchor)
 {
     return AnchorHelper.GetAnchoredPosition(Size, ViewportPosition, anchor);
 }