Esempio n. 1
0
        /**
         * @brief 객체가 x, y  좌표와 충돌하는가를 검사한다. 객체를 선택할려고 할때 호출된다.
         */
        public override Boolean checkHitAndSetSelectType(Pos posInRelativeSystem)
        {
            int  size = getVectorSize();
            Rect old  = null;

            setSelectType(SELECTTYPE.MOVE);
            for (int i = 0; i < size; i++)
            {
                Rect pt   = getVectorElementAt(i);
                Rect rect = new Rect(pt);
                rect.inflateRect(3, 3);
                if (rect.isHitPoint(posInRelativeSystem.x, posInRelativeSystem.y))
                {
                    //setSelectType(i);
                    setSelectType(SELECTTYPE.MOVE);
                    return(true);
                }
                if (old != null)
                {
                    if (LineHitTester.isLineHit(old.getLeft(), old.getTop(), pt.getLeft(), pt.getTop(), posInRelativeSystem.x, posInRelativeSystem.y))
                    {
                        return(true);
                    }
                }
                old = pt;
            }
            Rect pt2 = getVectorElementAt(0);

            if (LineHitTester.isLineHit(old.getLeft(), old.getTop(), pt2.getLeft(), pt2.getTop(), posInRelativeSystem.x, posInRelativeSystem.y))
            {
                return(true);
            }
            return(false);
        }
        /**
         * @brief 객체가 x,y 좌표와 충돌하는가를 검사한다. 객체를 선택하려고 할 때 호출된다.
         */
        public override Boolean checkHitAndSetSelectType(Pos posInRelativeSystem)
        {
            Rect rect = (Rect)getVectorElementAt(0);

            Rect rect2 = new Rect(
                rect.getLeft(),
                rect.getTop(),
                rect.getLeft(),
                rect.getTop());

            rect2.inflateRect(3, 3);
            if (rect2.isHitPoint(posInRelativeSystem.x, posInRelativeSystem.y))
            {
                setSelectType(SELECTTYPE.LEFT_TOP);
                return(true);
            }

            rect2 = new Rect(
                rect.getRight(),
                rect.getBottom(),
                rect.getRight(),
                rect.getBottom());
            rect2.inflateRect(3, 3);

            if (rect2.isHitPoint(posInRelativeSystem.x, posInRelativeSystem.y))
            {
                setSelectType(SELECTTYPE.RIGHT_BOTTOM);
                return(true);
            }

            setSelectType(SELECTTYPE.MOVE);
            return(LineHitTester.isLineHit(rect, posInRelativeSystem.x, posInRelativeSystem.y));
        }