A layer is an object that can be used on Scene
. It is a transparent sheet similar to Photoshop's layer. All the objects are added to Layer
in order to be displayed on the screen. Further, a scene can have multiple layers. Layers are also responsible for accepting inputs, drawing, and touching. For example, in the game, a scene has a background layer, hud layer, and a player's layer. In this recipe, we will explain how to use Layer
.
The following code shows how to create a layer and add it to a scene:
auto layer = Layer::create(); this->addChild(layer);
That's easy. If you have a color layer, you can do it.
auto layer = LayerColor::create(Color4B::WHITE); this->addChild(layer);