O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

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

Enemies attacking the buildings

In this task, we allow the enemy to stop and attack the buildings that block their way.

Prepare for lift off

The explode animation is made up of three graphics. We may use the bundled assets.js file for this, or we may use the following spritesheet image if we do not have access to Adobe Flash's assets features:

Prepare for lift off

Engage thrusters

Let's code the interactions between the enemies and buildings:

  1. We add the following damage logic to the building's base file:
    // The base of Building definition. ;(function(game, cjs, lib){ function Building(){ cjs.Container.call(this); // properties that need to be overridden this.hp = 100; this.shield ...

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