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...