我有一台相机,当我点击屏幕时,我需要慢慢地,平稳地(或不是)移动到指定的位置。那么如何让相机移动?
答案 0 :(得分:13)
使用SmoothCamera
。
以这种方式创建相机:
SmoothCamera camera = new SmoothCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
限制相机移动的最大速度:
camera.setMaxVelocity(MAX_VELOCITY_X, MAX_VELOCITY_Y);
在onSceneTouchEvent
方法中执行:
@Override
public boolean onSceneTouchEvent(final Scene pScene, final TouchEvent pTouchEvent) {
(SmoothCamera object here).setCenter(pTouchEvent.getX(), pTouchEvent.getY());
}