Thursday 4 April 2013

Overview about Manager Object


In Gdx Engine pretty much the Manager, a Manager to manage a group consisting of similar objects but most of the time we will use only one of these subjects. Some typical manager can take an example: camera, light or shadermanager.
Example, your game can have multiple scenes, but in time, you just need a scene. You can not both render "StartScene", rendering "GamePlayScene" same time! Similarly, you can have multiple cameras in a 3D game, FirstPersonShooter Camera, ThirdPersonShooter Camera, FixedCamera ... but in a moment can only use a single camera to observe the 3D object in the game only. You can not both at once both use FPS Camera use TPS Camera. Subjects are being used will be save reference in variablesactiveObject,You view BaseManager.java source for more details. The object Manager birth to provide a solution for managing the camera, the scene, the light, and more.
BaseManager is the superclass of all the manager of engine.Trong then BaseManager has built the basic method as get () ..., setactive ... (), add (), ... BaseManager is generic class so it can be used easily to create higher-level Manager is available or you can create new custom Manager. You only need to specify the class for thevalue key and class type for value its when creating a new Manager
Example: public class CameraManager extends BaseManager<String, Camera>{/ / do some stuffs ...} The
above code creates a CameraManager manage all cameras based on the key of each camera when be added to CameraManager's collection using the add method ... () of CameraManager
example:
//Add Camera Method in CameraManager class
public void addCamera (String key, Camera camera)
{
              if
                                (collection.containsKey ( key))
                                                throw new GdxRuntimeException ("Camera key is existing in CameraManager!");
                               
                                collection.put (key, camera);
}
Manager with ObjectCollection engine. ObjectCollection for a set of objects interact with each other directly and that is the object can display in GameScene. Manager is used for services and often only necessary to set the active object in a certain time while the game is running. ObjectCollection use ArrayList collection, also Manager usingHashMap. LightManager not need to use to method setactive ... () because in theory all the light in GameScene should be used at the same time rather than using each light individually.
BaseManager implements interface IService, meaning you can add it to the object service game easily.

No comments:

Post a Comment