Пример #1
0
    private void registerMovement()
    {
        if (!isLeftActive)
        {
            return;
        }

        //get distance first.
        tempDist  = Vector2.Distance(leftRgnCenter, LeftScnPos);
        tempSpeed = tempDist > distLimit ? 1.0f : tempDist / distMax; //OR DISTMAX?!


        //now get location to apply distance.
        if (LeftScnPos.x - leftRgnCenter.x > 0)
        {
            mCtrl.SetAxisDown("MoveHorizontal", tempSpeed);
        }
        else
        {
            mCtrl.SetAxisDown("MoveHorizontal", -tempSpeed);
        }

        if (LeftScnPos.y - leftRgnCenter.y > 0)
        {
            mCtrl.SetButtonDown("Jump");
        }
        else
        {
            mCtrl.SetButtonUp("Jump");
            mCtrl.SetButtonDown("DownJump");
        }
    }