コード例 #1
0
        //-------------------------------------------------------------------------
        InputController()
        {
            RenderFingerGesturesGameObject = GameObject.Find("Main Object");
            if (RenderFingerGesturesGameObject == null)
            {
                Debug.LogError("InputController init error -- Cannot found Main Object GameObject");
            }
            mClientFingerGestures = RenderFingerGesturesGameObject.GetComponent <ClientFingerGestures>();

            mClientFingerGestures.onFingerLongPress += (Vector2 fingerPos) =>
            {
                if (mActiveInput && onFingerLongPress != null)
                {
                    mCurrentMousePosition = pixel2logicPos(fingerPos);
                    onFingerLongPress(pixel2logicPos(fingerPos));
                }
            };

            mClientFingerGestures.onFingerUp += (Vector2 fingerPos) =>
            {
                if (mActiveInput && onFingerUp != null)
                {
                    mMouseDown            = false;
                    mCurrentMousePosition = pixel2logicPos(fingerPos);
                    onFingerUp();
                }
            };

            mClientFingerGestures.onFingerFingerSwipe += OnFingerSwipe;

            mClientFingerGestures.onFingerDown += onFingerDown;

            mClientFingerGestures.onFingerDragMove += (Vector2 fingerPos) =>
            {
                if (!mActiveInput)
                {
                    return;
                }

                mCurrentMousePosition = pixel2logicPos(fingerPos);

                if (mActiveInput && onFingerDragMove != null)
                {
                    onFingerDragMove(pixel2logicPos(fingerPos));
                }
            };

            mGameCamera = GameObject.Find("tk2dCameraObject").GetComponent <Camera>();
            mUICamera   = GameObject.Find("UI Camera").GetComponent <Camera>();
        }
コード例 #2
0
ファイル: InputController.cs プロジェクト: yinlei/Fishing
        //-------------------------------------------------------------------------
        InputController()
        {
            RenderFingerGesturesGameObject = GameObject.Find("Main Object");
            if (RenderFingerGesturesGameObject == null)
            {
                Debug.LogError("InputController init error -- Cannot found Main Object GameObject");
            }
            mClientFingerGestures = RenderFingerGesturesGameObject.GetComponent<ClientFingerGestures>();

            mClientFingerGestures.onFingerLongPress += (Vector2 fingerPos) =>
            {
                if (mActiveInput && onFingerLongPress != null)
                {
                    mCurrentMousePosition = pixel2logicPos(fingerPos);
                    onFingerLongPress(pixel2logicPos(fingerPos));
                }
            };

            mClientFingerGestures.onFingerUp += (Vector2 fingerPos) =>
            {
                if (mActiveInput && onFingerUp != null)
                {
                    mMouseDown = false;
                    mCurrentMousePosition = pixel2logicPos(fingerPos);
                    onFingerUp();
                }
            };

            mClientFingerGestures.onFingerFingerSwipe += OnFingerSwipe;

            mClientFingerGestures.onFingerDown += onFingerDown;

            mClientFingerGestures.onFingerDragMove += (Vector2 fingerPos) =>
            {
                if (!mActiveInput) return;

                mCurrentMousePosition = pixel2logicPos(fingerPos);

                if (mActiveInput && onFingerDragMove != null)
                {
                    onFingerDragMove(pixel2logicPos(fingerPos));
                }
            };

            mGameCamera = GameObject.Find("tk2dCameraObject").GetComponent<Camera>();
            mUICamera = GameObject.Find("UI Camera").GetComponent<Camera>();
        }