How to create a Layer
As mentioned previously, all entities are submitted to the engine through a subclass of the U4DEngine::U4DWorld class. Aside from submitting game entities into the rendering engine, you can also render Layers.
A layer is used to add UI Elements into your game. For example, a layer can contain buttons, images, shader objects, etc. Whenever, you create a layer and add it to the current view, the controller will point to your layer. Any user interaction will be detected by the layer and passed down the game model.
A layer is implemented using the U4DEngine::U4DLayer class. The code snippet below shows how to declare the U4DEngine::U4DLayer subclass.
Notice that the layer class requires a name to be provided. The init() method is where you would add game entities such as buttons, images, etc. The layer can also have a background image. This is accomplished by using the following method:
The MainMenuLayer object is then added to the U4DEngine::U4DWorld subclass through the use of the U4DEngine::U4DLayerManager as shown below:
Note, that you must push the layer in order for it to become active.
Creating a Layer without creating a subclass
This is another example of how to create a U4DEngine::U4DLayer without creating a subclass:
Last updated