O'Reilly logo

Learning Cocos2d-x Game Development by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the gameplay layer

In order to keep all the enemies and bullets in the same layer, we will create a new layer named GameplayLayer. This is where the gameplay will add and remove enemies and bullets, update their positions, and check for collisions. So, create a class named GameplayLayer similar to how you created the enemy class earlier.

Now, make sure that the GameplayLayer.h and GameplayLayer.cpp files are in the Classes folder. Once you have checked this, open the GameplayLayer.h file and add the following lines of code to it:

#ifndef __wp8Game__GameplayLayer__ #define __wp8Game__GameplayLayer__ #include "cocos2d.h" using namespace cocos2d; class GameplayLayer: public CCLayer { public: GameplayLayer(); ~GameplayLayer(); void update(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required