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

Chasing enemy behavior

In the Projectile shooting enemy section, we saw that when the projectile had the very basic behavior of just getting shot at the player, if the player moves away from the point of impact, the projectile doesn't do anything. In the chasing enemy AI, we will see how even if the player moves away, if the player is within radius of the projectile, the projectile will chase the player until there is a sufficient distance between the player and the projectile.

Getting ready

We will still use the same ShooterBase class. Instead of launching the ProjectileAI object, we will create a new class called ChaserAI and launch it instead. So, no major changes have to be made to the ShooterBase class, but we need to create a new ChaserAI ...

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