O'Reilly logo

Cocos2d Cross-Platform Game Development Cookbook - Second Edition 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

Projectile shooting enemy

Projectile enemies are enemies that toss objects, such as arrows and fireballs, at the player if the player comes close enough. For the projectile to hit the player, there is a base from which the projectile will be generated. Depending on the distance from the player, the base will launch the projectile at a calculated angle and speed so that the projectile can reach the player. Sometimes, to increase the chance of hitting the player, more than one projectile is shot. In this example, we will shoot just one projectile, but we will make sure that we give the player a tough time.

Getting ready

I included the assets for the base and the rocket in the resource folder, so make sure that they are included in the project.

We will ...

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