Created
May 25, 2014 18:55
-
-
Save azbesthu/675cd6d2cabc9c9fae48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private float mPreviousX; | |
private float mPreviousY; | |
private int mPreviousPointer; | |
private float mOriginalX; | |
private float mOriginalY; | |
@Override | |
public boolean onTouchEvent(MotionEvent e) { | |
// MotionEvent reports input details from the touch screen | |
// and other input controls. In this case, we are only | |
// interested in events where the touch position changed. | |
detector.onTouchEvent(e); | |
int pId = e.getPointerId(0); | |
float x = e.getX(); | |
float y = e.getY(); | |
float dx = x - mPreviousX; | |
float dy = y - mPreviousY; | |
switch (e.getAction()) { | |
case MotionEvent.ACTION_MOVE: | |
if (mPreviousPointer == pId) { | |
mRenderer.setTranslate(dx, dy); | |
} else { | |
mPreviousPointer = pId; | |
} | |
requestRender(); | |
break; | |
case MotionEvent.ACTION_DOWN: | |
mOriginalX = x; | |
mOriginalY = y; | |
break; | |
case MotionEvent.ACTION_UP: | |
if (Math.abs(mOriginalX-x)<5 && Math.abs(mOriginalY-y)<5){ | |
MyGLSurfaceView.touchedX = x; | |
MyGLSurfaceView.touchedY = y; | |
MyGLSurfaceView.ASK_FOR_KEY = true; | |
requestRender(); | |
} | |
break; | |
} | |
mPreviousX = x; | |
mPreviousY = y; | |
//invalidate(); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment