O'Reilly logo

iOS Game Programming Cookbook by Bhanu Birani, Chhavi Vaishnav

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

Implementing evade

Evade is similar to flee. The only difference between flee and evade is that in evade, the player will stop after fleeing to a safe location from the target location selected for evade. However, in flee, it just runs out of the screen from the target location and never comes back.

Getting ready

Technically, evade is to flee from the target to the safe location. The evade behavior will remain the same as the flee behavior, the only difference is that it will not run away infinitely from the target.

In this approach, when the target location is inside the safe range of the player, then the player will flee till the target location is not outside its safe range. So, in our case, we will make the player flee till the player is far ...

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