Introducing the camera object
Cameras can have many purposes when it comes to designing a large-scale game, but its main objective is to display a particular area of the game world on the device's display. This topic is going to introduce the base Camera
class, covering the general aspects of the camera in order to provide a reference for future camera use.
How to do it…
Cameras are important in game development as they control what we see on the device. Creating our camera is as easy as the following code:
final int WIDTH = 800; final int HEIGHT = 480; // Create the camera Camera mCamera = new Camera(0, 0, WIDTH, HEIGHT);
The WIDTH
and HEIGHT
values will define the area of the game's scene that will be displayed on the device.
How it works…
It's important to get to know the main functions of a camera in order to make the most of it in our projects. All of the different cameras inherit the methods found in this topic. Let's take a look at some of the most necessary camera methods needed for...