Book Image

HTML5 Game Development Hotshot

By : Seng Hin Mak, Makzan Makzan (Mak Seng Hin)
Book Image

HTML5 Game Development Hotshot

By: Seng Hin Mak, Makzan Makzan (Mak Seng Hin)

Overview of this book

Table of Contents (15 chapters)
HTML5 Game Development HOTSHOT
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Placing buildings on the floor


We are in the process of creating a building. We let the player choose the type of building in the previous task. In this task, we allow the players to choose where to place the selected building on the floor. There is a half-transparent building image following the cursor when selecting a tile to place the building. If the place is unavailable, we put a red overlay on top of the ghost building.

Prepare for lift off

We need the three building image files to be placed on the floor. Include the following three image files in the images folder of our project. The red overlay is added programmatically.

Planning the placing flow

This task involves both the UI layer and the city layer. We will use event dispatching for communication between these two components. There will be two custom events: newBuildingToBePlaced and placedBuilding. The following figure illustrates the event communication between both the layers in order to place the selected building on the floor...