Revision c896c0b3
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/magic/RubikSurfaceView.java | ||
---|---|---|
54 | 54 |
private int mButton = RubikSize.SIZE3.ordinal(); |
55 | 55 |
|
56 | 56 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
57 |
private int mX, mY;
|
|
57 |
private float mX, mY;
|
|
58 | 58 |
private int mLastTouchedFace; |
59 | 59 |
private float mCameraDistance; |
60 | 60 |
private int mScreenWidth, mScreenHeight, mScreenMin; |
... | ... | |
352 | 352 |
public boolean onTouchEvent(MotionEvent event) |
353 | 353 |
{ |
354 | 354 |
int action = event.getAction(); |
355 |
int x = (int)event.getX();
|
|
356 |
int y = (int)event.getY();
|
|
355 |
float x = event.getX() - mScreenWidth*0.5f;
|
|
356 |
float y = mScreenHeight*0.5f -event.getY();
|
|
357 | 357 |
|
358 | 358 |
switch(action) |
359 | 359 |
{ |
360 | 360 |
case MotionEvent.ACTION_DOWN: mX = x; |
361 | 361 |
mY = y; |
362 |
mLastTouchedFace = mMovement.faceTouched(mQuatAccumulated,mCameraDistance, x,y, mScreenWidth, mScreenHeight);
|
|
362 |
mLastTouchedFace = mMovement.faceTouched(mQuatAccumulated,mCameraDistance, x, y);
|
|
363 | 363 |
|
364 | 364 |
if( mLastTouchedFace != RubikCubeMovement.NONE ) |
365 | 365 |
{ |
... | ... | |
376 | 376 |
break; |
377 | 377 |
case MotionEvent.ACTION_MOVE: if( mDragging ) |
378 | 378 |
{ |
379 |
mTempCurrent.set(quatFromDrag(mX-x,mY-y));
|
|
379 |
mTempCurrent.set(quatFromDrag(mX-x,y-mY));
|
|
380 | 380 |
mRenderer.setQuatCurrentOnNextRender(); |
381 | 381 |
|
382 | 382 |
int minimumDist = (mScreenMin*mScreenMin)/(DIRECTION_SENSITIVITY*DIRECTION_SENSITIVITY); |
... | ... | |
397 | 397 |
|
398 | 398 |
if( (mX-x)*(mX-x)+(mY-y)*(mY-y) > minimumDistToStartRotating ) |
399 | 399 |
{ |
400 |
mMovement.addNewRotation(mQuatAccumulated,mLastTouchedFace, x,y, mScreenWidth, mScreenHeight);
|
|
400 |
mMovement.addNewRotation(mQuatAccumulated,mLastTouchedFace, x, y);
|
|
401 | 401 |
mBeginningRotation = false; |
402 | 402 |
mContinuingRotation= true; |
403 | 403 |
} |
404 | 404 |
} |
405 | 405 |
else if( mContinuingRotation ) |
406 | 406 |
{ |
407 |
mMovement.continueRotation(mQuatAccumulated,mLastTouchedFace, x,y, mScreenWidth, mScreenHeight);
|
|
407 |
mMovement.continueRotation(mQuatAccumulated,mLastTouchedFace, x, y, mScreenMin);
|
|
408 | 408 |
} |
409 | 409 |
break; |
410 | 410 |
case MotionEvent.ACTION_UP : if( mDragging ) |
Also available in: Unified diff
Simplifications for object movement.