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

Creating the projectile class

Now that we have the enemies spawning, we want them to shoot bullets at certain intervals. The bullets will spawn wherever the enemy is currently located. Once they have spawned, they should start moving left and once they are out of the screen, they should be deleted. For this, we create a class named Projectile and add the Projectile.h and Projectile.cpp files to the Classes folder, as we did previously for the other classes.

In the Projectile.h file, add the following lines of code:

#ifndef __wp8Game__Projectile__ #define __wp8Game__Projectile__ #pragma once #include "cocos2d.h" using namespace cocos2d; class Projectile : public CCSprite { public: Projectile(void); ~Projectile(void); int type; static Projectile* ...

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