HTML and CSS Reference
In-Depth Information
12. To make the custom event dispatch and listening work, we need to iniialize the
game object to have the EventDispatcher capabiliies. We iniialize it inside
the game.start funcion:
Objective complete - mini debriefing
The BuildingsList is a list containing all the buildings and their current state. The state
includes the building type and the isometric coordinates. Later, we will add more variables
to the building data, including the construcion staisics.
Conversion from screen coordinates to isometric coordinates
When the mouse moves over to the floor, we have the coordinates of a 2D screen. We need
a conversion between the screen and isometric coordinates for the cursor movement and
clicks. By calculaing the isoX and isoY coordinates that the cursor is poining to, we can get
the selected ile in the isometric world. We deined each building's registraion point on the
isometric grid. From the registraion point of the selected ile, we know where the ghost
building or the new building should be placed. Let's recap the code to archive this conversion:
var localPt = _this.globalToLocal(e.stageX, e.stageY);
var isoCoord = game.isoMaths.screenToIsoCoord
(localPt.x, localPt.y);
var tileScreenCoord = game.isoMaths.isoToScreenCoord
(isoCoord.x, isoCoord.y);
The following figure illustrates the steps to convert a stage's x and y coordinates into the city
layer's isometric world and the inal registraion point in the screen coordinates:
Search WWH ::

Custom Search