Creating smooth moves with a smooth camera
The SmoothCamera
object is the most advanced of the four cameras to choose from. This camera allows for all of the different types of camera functionality (bounds, zooming, and so on) with an additional option to apply a defined velocity to the camera's movement speed upon setting a new position for the camera. The result may appear as if the camera "eases" in and out of movement, allowing for rather subtle camera movements.
How to do it…
This camera type is the only one of the four which requires additional parameters to be defined in the constructor. These extra parameters include the maximum x and y velocities in which the camera can travel and the maximum zoom factor change which handles the speed that the camera will zoom in and out. Let's take a look at what this camera creation will look like:
// Camera movement speeds final float maxVelocityX = 10; final float maxVelocityY = 5; // Camera zoom speed final float maxZoomFactorChange = 5; ...