@Test public void testDefaultInitialization() { final float WORLD_WIDTH = 500; final float WORLD_HEIGHT = 800; setCameraBounds(0f, 0f, WORLD_WIDTH, WORLD_HEIGHT); setWorldBounds(0f, 0f, WORLD_WIDTH, WORLD_HEIGHT); camera.update(0f); assertThat(orthographicCamera.position.len()).isZero(); assertThat(orthographicCamera.viewportWidth).isEqualTo(WORLD_WIDTH); assertThat(orthographicCamera.viewportHeight).isEqualTo(WORLD_HEIGHT); }
@Override public void update(float delta) { camera.position.x -= lastShake.x; camera.position.y -= lastShake.y; if (target != null) { currentWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); if (!currentWorldBounds.equals(previousWorldBounds)) { correctionX = 0; correctionY = 0; } if (focusRequested) { focusCentered(target); focusRequested = false; } else { applyTrackingVelocityAndZoom(delta); } if (worldBoundsStickiness) { applyWorldBounds(); } previousWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); } camera.position.x += shake.x; camera.position.y += shake.y; camera.update(); lastShake.set(shake); }
VectorGameCamera implements GameCamera { @Override public void update(float delta) { camera.position.x -= lastShake.x; camera.position.y -= lastShake.y; if (target != null) { currentWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); if (!currentWorldBounds.equals(previousWorldBounds)) { correctionX = 0; correctionY = 0; } if (focusRequested) { focusCentered(target); focusRequested = false; } else { applyTrackingVelocityAndZoom(delta); } if (worldBoundsStickiness) { applyWorldBounds(); } previousWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); } camera.position.x += shake.x; camera.position.y += shake.y; camera.update(); lastShake.set(shake); } }
VectorGameCamera implements GameCamera { @Override public void update(float delta) { camera.position.x -= lastShake.x; camera.position.y -= lastShake.y; if (target != null) { currentWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); if (!currentWorldBounds.equals(previousWorldBounds)) { correctionX = 0; correctionY = 0; } if (focusRequested) { focusCentered(target); focusRequested = false; } else { applyTrackingVelocityAndZoom(delta); } if (worldBoundsStickiness) { applyWorldBounds(); } previousWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); } camera.position.x += shake.x; camera.position.y += shake.y; camera.update(); lastShake.set(shake); } VectorGameCamera(OrthographicCamera camera, GameWorld world); }
VectorGameCamera implements GameCamera { @Override public void update(float delta) { camera.position.x -= lastShake.x; camera.position.y -= lastShake.y; if (target != null) { currentWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); if (!currentWorldBounds.equals(previousWorldBounds)) { correctionX = 0; correctionY = 0; } if (focusRequested) { focusCentered(target); focusRequested = false; } else { applyTrackingVelocityAndZoom(delta); } if (worldBoundsStickiness) { applyWorldBounds(); } previousWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); } camera.position.x += shake.x; camera.position.y += shake.y; camera.update(); lastShake.set(shake); } VectorGameCamera(OrthographicCamera camera, GameWorld world); @Override void setTrackingTarget(GameObject target); @Override void setTrackingTarget(GameObject target, boolean focus); @Override void update(float delta); @Override float getZoomModeValue(); @Override void setDistanceStoppingThreshold(float distanceThreshold); @Override void resize(int width, int height); @Override float getDefaultZoomFactor(); @Override void setDefaultZoomFactor(float zoom); @Override void zoom(float amount); @Override void setZoom(float value, ZoomMode zoomMode); @Override void setZoom(float value); @Override void setTargetTrackingSpeed(float speed); @Override void setTargetTrackingSpeed(float speedX, float speedY); @Override void setZoomScalingFactor(float zoomScale); @Override void focusCentered(GameObject object); @Override void focusCentered(); @Override Camera getInternalCamera(); @Override void setPosition(float x, float y); @Override Vector3 getPosition(); @Override float getDistanceTo(float targetX, float targetY); @Override float getDistanceTo(GameObject gameObject); @Override float getScaledCameraWidth(); @Override float getScaledCameraHeight(); @Override float getUnscaledCameraWidth(); @Override float getUnscaledCameraHeight(); @Override float getLeft(); @Override float getTop(); @Override float getTargetTrackingSpeed(); @Override float getTargetTrackingSpeedX(); @Override float getTargetTrackingSpeedY(); @Override void shake(float strength, float duration); @Override Vector2 getShake(); @Override void setStickToWorldBounds(boolean enabled); }
VectorGameCamera implements GameCamera { @Override public void update(float delta) { camera.position.x -= lastShake.x; camera.position.y -= lastShake.y; if (target != null) { currentWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); if (!currentWorldBounds.equals(previousWorldBounds)) { correctionX = 0; correctionY = 0; } if (focusRequested) { focusCentered(target); focusRequested = false; } else { applyTrackingVelocityAndZoom(delta); } if (worldBoundsStickiness) { applyWorldBounds(); } previousWorldBounds.set( world.getBounds().getWorldOffsetX(), world.getBounds().getWorldOffsetY(), world.getBounds().getWorldWidth(), world.getBounds().getWorldHeight() ); } camera.position.x += shake.x; camera.position.y += shake.y; camera.update(); lastShake.set(shake); } VectorGameCamera(OrthographicCamera camera, GameWorld world); @Override void setTrackingTarget(GameObject target); @Override void setTrackingTarget(GameObject target, boolean focus); @Override void update(float delta); @Override float getZoomModeValue(); @Override void setDistanceStoppingThreshold(float distanceThreshold); @Override void resize(int width, int height); @Override float getDefaultZoomFactor(); @Override void setDefaultZoomFactor(float zoom); @Override void zoom(float amount); @Override void setZoom(float value, ZoomMode zoomMode); @Override void setZoom(float value); @Override void setTargetTrackingSpeed(float speed); @Override void setTargetTrackingSpeed(float speedX, float speedY); @Override void setZoomScalingFactor(float zoomScale); @Override void focusCentered(GameObject object); @Override void focusCentered(); @Override Camera getInternalCamera(); @Override void setPosition(float x, float y); @Override Vector3 getPosition(); @Override float getDistanceTo(float targetX, float targetY); @Override float getDistanceTo(GameObject gameObject); @Override float getScaledCameraWidth(); @Override float getScaledCameraHeight(); @Override float getUnscaledCameraWidth(); @Override float getUnscaledCameraHeight(); @Override float getLeft(); @Override float getTop(); @Override float getTargetTrackingSpeed(); @Override float getTargetTrackingSpeedX(); @Override float getTargetTrackingSpeedY(); @Override void shake(float strength, float duration); @Override Vector2 getShake(); @Override void setStickToWorldBounds(boolean enabled); static final float STEP_INTERVAL; }