我有一个应用程序:支持触摸和按键的 3D Cube (OPENGLES)。我正在使用 KEYCODE_VOLUME_UP/DOWN 放大/缩小。负责的方法放在: MyGLSurfaceView extends GLSurfaceView。我的问题是,当我按下缩小/int 时,它工作正常,但我也有音量增大/减小功能。有可能快速解决这个问题吗?
代码:
@Override
public boolean onKeyUp(int keyCode, KeyEvent evt) {
switch(keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT: // Decrease Y-rotational speed
renderer.speedY -= 0.3f;
break;
case KeyEvent.KEYCODE_DPAD_RIGHT: // Increase Y-rotational speed
renderer.speedY += 0.3f;
break;
case KeyEvent.KEYCODE_DPAD_UP: // Decrease X-rotational speed
renderer.speedX -= 0.3f;
break;
case KeyEvent.KEYCODE_DPAD_DOWN: // Increase X-rotational speed
renderer.speedX += 0.3f;
break;
case KeyEvent.KEYCODE_VOLUME_DOWN:// Zoom out (decrease z)
renderer.z -= 0.4f;
break;
case KeyEvent.KEYCODE_VOLUME_UP: // Zoom in (increase z)
renderer.z += 0.4f;
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
renderer.speedY = 0;
renderer.speedX = 0;
renderer.z = -6.0f;
break;
}
return true;
}