June 2013
Intermediate to advanced
346 pages
8h 42m
English
Now that we’re able to test if the mallet has been touched, we’ll work on solving the next part of the puzzle: Where does the mallet go when we drag it around? We can think of things in this way: the mallet lies flat on the table, so when we move our finger around, the mallet should move with our finger and continue to lie flat on the table. We can figure out the right position by doing a ray-plane intersection test.
Let’s complete the definition for handleTouchDrag:
| AirHockeyTouch/src/com/airhockey/android/AirHockeyRenderer.java | |
| | public void handleTouchDrag(float normalizedX, float normalizedY) { |
| | if (malletPressed) { |
| | Ray ray = convertNormalized2DPointToRay(normalizedX, normalizedY); |
| | // Define ... |
Read now
Unlock full access