xnapunk.colliders.RectangleCollider.GetTopLeft C# (CSharp) Method

GetTopLeft() public method

public GetTopLeft ( ) : Vector2
return Vector2
        public Vector2 GetTopLeft()
        {
            return new Vector2(GetLeft(), GetTop());
        }

Usage Example

Beispiel #1
0
        private static bool CollideRectCirc(RectangleCollider a, CircleCollider b)
        {
            if (a.IntersectsPoint(b.GetCenter()))
                return true;

            //Check the circle against the four edges of the rectangle
            Vector2 pA = a.GetTopLeft();
            Vector2 pB = a.GetTopRight();
            Vector2 pC = a.GetBottomRight();
            Vector2 pD = a.GetBottomLeft();
            if (b.IntersectsLine(pA, pB, 0) || b.IntersectsLine(pB, pC, 0) || b.IntersectsLine(pC, pD, 0) || b.IntersectsLine(pD, pA, 0))
                return true;

            return false;
        }