Skip to content
Anselme Clergeot edited this page May 31, 2015 · 19 revisions

Welcome to the FisoEngine tutorial on how to use the camera system!

Using a camera can be useful for many games.

1) What is a camera?

A camera is a class that represents a view on an etablished world (here our isometric map). Here, the Camera class is a simplified version of a camera system that contains two informations:

  • The view width and height (the dimensions of the view part).
  • The view center (on which coordinates of the world the camera is looking at).

Using a camera may be useful if you want to focus on specific elements of the map at different moments or if you want the camera to follow the main player, etc.

2) Wait, I already have a Camera instance!

Yes! Remember, you already set a Camera instance just before initializing your Map object. Why? Because the Map needs a reference to the Camera to initialize its members (some needs camera view dimensions to know if they are visible, etc.).
So, you don't have to do anything more. Your Camera is ready!

3) Setting the view dimensions of your Camera

Remember, you already done this operation. This is used to set the camera view dimensions:

cam.setViewDimensions(yourDimensions);

You can change the view dimensions of your camera at any moments.

4) Setting the view center of your camera

If you want the camera to look at specific coordinates of the world, like your character of anything else, you have to call:

cam.setViewCenter(yourWorldCoordinates);

As the same way, you also can move the view center of the camera by doing:

cam.moveViewCenter(yourMoveRate);

5) Changing the map-active camera

To change the camera of your Map, you have to call :

myMap.setCamera(yourCamera);

Now, the active camera of your Map is "yourCamera".

6) Accessors

You can access different informations of your camera.

Get the view dimensions
cam.getViewDimensions();
Get the view center
cam.getViewCenter();

Well done ! You master the FisoEngine camera system !