Java Code Examples for org.andengine.input.touch.TouchEvent#getY()
The following examples show how to use
org.andengine.input.touch.TouchEvent#getY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Camera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public void convertSceneToSurfaceTouchEvent(final TouchEvent pSceneTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) { this.convertAxisAlignedSceneToSurfaceTouchEvent(pSceneTouchEvent, pSurfaceWidth, pSurfaceHeight); final float rotation = this.mRotation; if(rotation == 0) { /* Nothing to do. */ } else if(rotation == 180) { pSceneTouchEvent.set(pSurfaceWidth - pSceneTouchEvent.getX(), pSurfaceHeight - pSceneTouchEvent.getY()); } else { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 2
Source File: Camera.java From tilt-game-android with MIT License | 6 votes |
public void convertSurfaceTouchEventToSceneTouchEvent(final TouchEvent pSurfaceTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) { final float relativeX; final float relativeY; final float surfaceTouchEventX = pSurfaceTouchEvent.getX(); final float surfaceTouchEventY = pSurfaceTouchEvent.getY(); final float rotation = this.mRotation; if (rotation == 0) { relativeX = surfaceTouchEventX / pSurfaceWidth; relativeY = 1 - (surfaceTouchEventY / pSurfaceHeight); } else if (rotation == 180) { relativeX = 1 - (surfaceTouchEventX / pSurfaceWidth); relativeY = surfaceTouchEventY / pSurfaceHeight; } else { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = surfaceTouchEventX; Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = surfaceTouchEventY; MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); // TODO Use a Transformation object instead!?! relativeX = Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] / pSurfaceWidth; relativeY = 1 - (Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] / pSurfaceHeight); } this.convertAxisAlignedSurfaceTouchEventToSceneTouchEvent(pSurfaceTouchEvent, relativeX, relativeY); }
Example 3
Source File: Camera.java From tilt-game-android with MIT License | 6 votes |
public void convertSceneTouchEventToSurfaceTouchEvent(final TouchEvent pSceneTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) { this.convertAxisAlignedSceneToSurfaceTouchEvent(pSceneTouchEvent, pSurfaceWidth, pSurfaceHeight); final float rotation = this.mRotation; if (rotation == 0) { /* Nothing. */ } else if (rotation == 180) { pSceneTouchEvent.setY(pSurfaceHeight - pSceneTouchEvent.getY()); pSceneTouchEvent.setX(pSurfaceWidth - pSceneTouchEvent.getX()); } else { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, -rotation, pSurfaceWidth >> 1, pSurfaceHeight >> 1); // TODO Use a Transformation object instead!?! pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 4
Source File: HoldDetector.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
protected void prepareHold(final TouchEvent pSceneTouchEvent) { final MotionEvent motionEvent = pSceneTouchEvent.getMotionEvent(); this.mDownTimeMilliseconds = System.currentTimeMillis(); this.mDownX = motionEvent.getX(); this.mDownY = motionEvent.getY(); this.mMaximumDistanceExceeded = false; this.mPointerID = pSceneTouchEvent.getPointerID(); this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); if(this.mTriggerHoldMinimumMilliseconds == 0) { this.triggerOnHoldStarted(); } }
Example 5
Source File: Camera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private void unapplyCameraSceneRotation(final TouchEvent pCameraSceneTouchEvent) { final float cameraSceneRotation = -this.mCameraSceneRotation; if(cameraSceneRotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.getY(); MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, cameraSceneRotation, (this.mXMax - this.mXMin) * 0.5f, (this.mYMax - this.mYMin) * 0.5f); pCameraSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 6
Source File: Camera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private void applyCameraSceneRotation(final TouchEvent pSceneTouchEvent) { final float cameraSceneRotation = -this.mCameraSceneRotation; if(cameraSceneRotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, cameraSceneRotation, (this.mXMax - this.mXMin) * 0.5f, (this.mYMax - this.mYMin) * 0.5f); pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 7
Source File: Camera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private void convertAxisAlignedSceneToSurfaceTouchEvent(final TouchEvent pSceneTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) { final float xMin = this.getXMin(); final float xMax = this.getXMax(); final float yMin = this.getYMin(); final float yMax = this.getYMax(); final float relativeX = (pSceneTouchEvent.getX() - xMin) / (xMax - xMin); final float relativeY = (pSceneTouchEvent.getY() - yMin) / (yMax - yMin); pSceneTouchEvent.set(relativeX * pSurfaceWidth, relativeY * pSurfaceHeight); }
Example 8
Source File: Camera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
private void applySceneRotation(final TouchEvent pCameraSceneTouchEvent) { final float rotation = this.mRotation; if(rotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.getY(); MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, -rotation, this.getCenterX(), this.getCenterY()); pCameraSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 9
Source File: ZoomCamera.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override protected void applySceneToCameraSceneOffset(final TouchEvent pSceneTouchEvent) { final float zoomFactor = this.mZoomFactor; if(zoomFactor != 1) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.scaleAroundCenter(Camera.VERTICES_TMP, zoomFactor, zoomFactor, this.getCenterX(), this.getCenterY()); // TODO Use a Transformation object instead!?! pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } super.applySceneToCameraSceneOffset(pSceneTouchEvent); }
Example 10
Source File: HoldDetector.java From tilt-game-android with MIT License | 5 votes |
protected void prepareHold(final TouchEvent pSceneTouchEvent) { final MotionEvent motionEvent = pSceneTouchEvent.getMotionEvent(); this.mDownTimeMilliseconds = System.currentTimeMillis(); this.mDownX = motionEvent.getX(); this.mDownY = motionEvent.getY(); this.mMaximumDistanceExceeded = false; this.mPointerID = pSceneTouchEvent.getPointerID(); this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); if (this.mTriggerHoldMinimumMilliseconds == 0) { this.triggerOnHoldStarted(); } }
Example 11
Source File: Camera.java From tilt-game-android with MIT License | 5 votes |
private void convertAxisAlignedSceneToSurfaceTouchEvent(final TouchEvent pSceneTouchEvent, final int pSurfaceWidth, final int pSurfaceHeight) { final float xMin = this.getXMin(); final float xMax = this.getXMax(); final float yMin = this.getYMin(); final float yMax = this.getYMax(); final float relativeX = (pSceneTouchEvent.getX() - xMin) / (xMax - xMin); final float relativeY = 1 - (pSceneTouchEvent.getY() - yMin) / (yMax - yMin); final float x = relativeX * pSurfaceWidth; final float y = relativeY * pSurfaceHeight; pSceneTouchEvent.set(x, y); }
Example 12
Source File: Camera.java From tilt-game-android with MIT License | 5 votes |
private void unapplyCameraSceneRotation(final TouchEvent pCameraSceneTouchEvent) { final float cameraSceneRotation = this.mCameraSceneRotation; if (cameraSceneRotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.getY(); MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, cameraSceneRotation, this.getCameraSceneWidth() * 0.5f, this.getCameraSceneHeight() * 0.5f); // TODO Use a Transformation object instead!?! pCameraSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 13
Source File: Camera.java From tilt-game-android with MIT License | 5 votes |
private void applyCameraSceneRotation(final TouchEvent pSceneTouchEvent) { final float cameraSceneRotation = this.mCameraSceneRotation; if (cameraSceneRotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, cameraSceneRotation, this.getCameraSceneWidth() * 0.5f, this.getCameraSceneHeight() * 0.5f); // TODO Use a Transformation object instead!?! pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 14
Source File: Camera.java From tilt-game-android with MIT License | 5 votes |
private void unapplySceneRotation(final TouchEvent pSceneTouchEvent) { final float rotation = this.mRotation; if (rotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.revertRotateAroundCenter(Camera.VERTICES_TMP, rotation, this.getCenterX(), this.getCenterY()); // TODO Use a Transformation object instead!?! pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 15
Source File: Camera.java From tilt-game-android with MIT License | 5 votes |
private void applySceneRotation(final TouchEvent pCameraSceneTouchEvent) { final float rotation = this.mRotation; if (rotation != 0) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pCameraSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pCameraSceneTouchEvent.getY(); MathUtils.rotateAroundCenter(Camera.VERTICES_TMP, rotation, this.getCenterX(), this.getCenterY()); // TODO Use a Transformation object instead!?! pCameraSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } }
Example 16
Source File: ZoomCamera.java From tilt-game-android with MIT License | 5 votes |
@Override protected void applySceneToCameraSceneOffset(final TouchEvent pSceneTouchEvent) { final float zoomFactor = this.mZoomFactor; if (zoomFactor != 1) { Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X] = pSceneTouchEvent.getX(); Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y] = pSceneTouchEvent.getY(); MathUtils.scaleAroundCenter(Camera.VERTICES_TMP, zoomFactor, zoomFactor, this.getCenterX(), this.getCenterY()); // TODO Use a Transformation object instead!?! pSceneTouchEvent.set(Camera.VERTICES_TMP[Constants.VERTEX_INDEX_X], Camera.VERTICES_TMP[Constants.VERTEX_INDEX_Y]); } super.applySceneToCameraSceneOffset(pSceneTouchEvent); }
Example 17
Source File: ScrollDetector.java From tilt-game-android with MIT License | 4 votes |
protected float getY(final TouchEvent pTouchEvent) { return pTouchEvent.getY(); }
Example 18
Source File: ContinuousHoldDetector.java From tilt-game-android with MIT License | 4 votes |
@Override public boolean onManagedTouchEvent(final TouchEvent pSceneTouchEvent) { final MotionEvent motionEvent = pSceneTouchEvent.getMotionEvent(); switch (pSceneTouchEvent.getAction()) { case TouchEvent.ACTION_DOWN: if (this.mPointerID == TouchEvent.INVALID_POINTER_ID) { this.prepareHold(pSceneTouchEvent); return true; } else { return false; } case TouchEvent.ACTION_MOVE: { if (this.mPointerID == pSceneTouchEvent.getPointerID()) { this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); this.mMaximumDistanceExceeded = this.mMaximumDistanceExceeded || Math.abs(this.mDownX - motionEvent.getX()) > this.mTriggerHoldMaximumDistance || Math.abs(this.mDownY - motionEvent.getY()) > this.mTriggerHoldMaximumDistance; return true; } else { return false; } } case TouchEvent.ACTION_UP: case TouchEvent.ACTION_CANCEL: { if (this.mPointerID == pSceneTouchEvent.getPointerID()) { this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); if (this.mTriggering) { this.triggerOnHoldFinished(motionEvent.getEventTime() - this.mDownTimeMilliseconds); } this.mPointerID = TouchEvent.INVALID_POINTER_ID; return true; } else { return false; } } default: return false; } }
Example 19
Source File: ScrollDetector.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
protected float getY(final TouchEvent pTouchEvent) { return pTouchEvent.getY(); }
Example 20
Source File: ContinuousHoldDetector.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
@Override public boolean onManagedTouchEvent(final TouchEvent pSceneTouchEvent) { final MotionEvent motionEvent = pSceneTouchEvent.getMotionEvent(); switch(pSceneTouchEvent.getAction()) { case TouchEvent.ACTION_DOWN: if(this.mPointerID == TouchEvent.INVALID_POINTER_ID) { this.prepareHold(pSceneTouchEvent); return true; } else { return false; } case TouchEvent.ACTION_MOVE: { if(this.mPointerID == pSceneTouchEvent.getPointerID()) { this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); this.mMaximumDistanceExceeded = this.mMaximumDistanceExceeded || Math.abs(this.mDownX - motionEvent.getX()) > this.mTriggerHoldMaximumDistance || Math.abs(this.mDownY - motionEvent.getY()) > this.mTriggerHoldMaximumDistance; return true; } else { return false; } } case TouchEvent.ACTION_UP: case TouchEvent.ACTION_CANCEL: { if(this.mPointerID == pSceneTouchEvent.getPointerID()) { this.mHoldX = pSceneTouchEvent.getX(); this.mHoldY = pSceneTouchEvent.getY(); if(this.mTriggering) { this.triggerOnHoldFinished(motionEvent.getEventTime() - this.mDownTimeMilliseconds); } this.mPointerID = TouchEvent.INVALID_POINTER_ID; return true; } else { return false; } } default: return false; } }