Using a camera - AnselmeClergeot/FisoEngine GitHub Wiki
Using a camera can be useful for many games.
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.
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!
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.
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);To change the camera of your Map, you have to call :
myMap.setCamera(yourCamera);Now, the active camera of your Map is "yourCamera".
You can access different informations of your camera.
cam.getViewDimensions();cam.getViewCenter();