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* ...

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.