//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions //---------------------- // Protected Functions //---------------------- // Private Functions /// <summary> /// Do the screen scroll algorithm. /// </summary> private void DoScreenScroll() { if (!mScreenScroll) { return; } // get mouse position range from 0 to 1 Vector2 mouse01 = JCS_Input.MousePosition0To1(); // get the 4 bounds. float rightBound = 1 - mScrollScreenRange; float leftBound = mScrollScreenRange; float topBound = 1 - mScrollScreenRange; float botBound = mScrollScreenRange; //-- check x direction. --// if (mouse01.x <= leftBound) // left bound check { // if the mouse pos reach the left bound // minus the velocity so it will go left. mVelocity.x = -mScrollScreenSpeed; } else if (mouse01.x >= rightBound) // right bound check { // if the mouse pos reach the right bound // plus the velocity so it will go right. mVelocity.x = mScrollScreenSpeed; } else { // else apply zero, so it wont move. mVelocity.x = 0; } //-- check y direction. --// if (mouse01.y <= botBound) // bot bound check { if (mScrollDepth) { // if the mouse pos reach the bottom bound // minus the velocity so it will go backward. mVelocity.z = -mScrollScreenSpeed; } else { // if the mouse pos reach the bottom bound // minus the velocity so it will go down. mVelocity.y = mScrollScreenSpeed; } } else if (mouse01.y >= topBound) // top bound check { if (mScrollDepth) { // if the mouse pos reach the top bound // plus the velocity so it will go forward. mVelocity.z = mScrollScreenSpeed; } else { // if the mouse pos reach the top bound // plus the velocity so it will go top. mVelocity.y = mScrollScreenSpeed; } } else { // else apply zero, so it wont move. mVelocity.z = 0; } }