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

Collecting pop-up diamonds

In this task, we make the diamonds pop up from merchant buildings to let the player click on the diamonds and collect them in order to increase the diamond count.

Prepare for lift off

Before getting started with the steps of this task, we want to ensure that we have the following diamond sprite graphic files prepared and placed in the images folder:

Prepare for lift off

Engage thrusters

In the following steps, we add the diamond animation to the stage and let the players click on it:

  1. We have a new display object so we will add the diamond sprite to the view-sprites.js file:
     (game.Diamond = function() { cjs.Container.call(this); // super var data ...

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