在设备旋转时旋转相机
Rotate camera on device rotation
如何在设备旋转时旋转相机?
这是我尝试做的:
float[] f = new float[16];
Gdx.input.getRotationMatrix( f );
Matrix4 m = new Matrix4( f );
m = m.scl( 0.01f );
cam.rotate( m );
cam.update();
相机旋转太快了,但也可能不正确。有什么想法吗?
我认为使用加速度计旋转相机会比旋转矩阵更容易。
如果这是二维的,你会使用:
cam.rotate(Gdx.input.getAccelerometerX()*SCALE);
这会在您向左或向右倾斜设备时旋转相机。
如何在设备旋转时旋转相机?
这是我尝试做的:
float[] f = new float[16];
Gdx.input.getRotationMatrix( f );
Matrix4 m = new Matrix4( f );
m = m.scl( 0.01f );
cam.rotate( m );
cam.update();
相机旋转太快了,但也可能不正确。有什么想法吗?
我认为使用加速度计旋转相机会比旋转矩阵更容易。
如果这是二维的,你会使用:
cam.rotate(Gdx.input.getAccelerometerX()*SCALE);
这会在您向左或向右倾斜设备时旋转相机。