@Override public void tact(long now, long period) { final float nextStep = MathUtils.distance(mPoint.x, mPoint.y, mNextPoint.x, mNextPoint.y); if (nextStep > 10) { float distance = (float) period / 1000 * mSpeed; float m = nextStep - distance; float x = (m * mPoint.x + distance * mNextPoint.x) / nextStep; float y = (m * mPoint.y + distance * mNextPoint.y) / nextStep; mPoint.x = x; mPoint.y = y; } mSprite.setPosition(mPoint.x - mPointOffset.x, mPoint.y - mPointOffset.y); mSpriteShadow.setPosition(mSprite.getX() + mPointShadow.x, mSprite.getY() + mPointShadow.y); }
/** Calculate the euclidian distance between the first two fingers. */ private static float calculatePointerDistance(final MotionEvent pMotionEvent) { return MathUtils.distance( pMotionEvent.getX(0), pMotionEvent.getY(0), pMotionEvent.getX(1), pMotionEvent.getY(1)); }