Creating the HUD layer and displaying as well as updating scores

HUD is usually used to display information to the player such as score, health, and points. In our game, we are going to add the score variable we previously created in the HelloWorldScene files and move it to this layer for convenience.

Similar to how we created GameplayLayer, we will create HUDLayer. So, now in your Classes folder in the system, you will have HUDLayer.h and HUDLayer.cpp; add them in the Solution Explorer panel in the Classes tab by clicking on Add existing file.

In the HUDLayer.h file, add the following code:

#ifndef __wp8Game__HUDLayer__ #define __wp8Game__HUDLayer__ #pragma once #include "cocos2d.h" using namespace cocos2d; class HelloWorldScene; class HUDLayer ...

Get Learning Cocos2d-x Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.