Game Development Reference
In-Depth Information
Figure 4-6.
Icosahedron in action
Next, you simply check the number of active fingers. A value of 1 indicates a swipe,
2 indicates a pinch. If swiping, you call the
setRotationSpeed(DX1)
function with the delta
coordinates for the first finger in the X axis. If pinching, you call
setPinch(DX1, DX2)
with the
deltas for both fingers in the X coordinate.
When swiping to the left, the delta X value is negative; it is positive when swiping to
the right. In either case, you decrease or increase the rotation speed and call the view's
setRotationSpeed
function, which invokes
doSetRotation
in C++.
if (DX < 0) {
speed -= 20;
} else {
speed += 20;
}
// clamp 0-100
if (speed < 0)
speed = 0;
if (speed > 100)
speed = 100;
view.setRotationSpeed(speed);