MergeOntoThis can be used to merge tiles from one or more source layers into a destination layer. Merging can be used for a number of reasons:
To simplify management of layers
To improve performance
This example uses a tmx file which includes a layer named Layer2 which contains ice blocks.
The other tiles (the red number 1 and the orange brick surrounding blocks) are part of the GameplayLayer - the standard layout for Level1 if using the wizard. The following code shows how to merge the layers:
The code above includes diagnostic variables to count quads and layers. These values can help verify that the layers have been merged at runtime as shown in the following screenshot:
Even though layer2 has been destroyed, the ice blocks still draw as shown in the following screenshot:
Note that LayeredTileMaps partition their tiles based on the X or Y axis, so merging is not simply an addition of quads at the end of the layer. Rather, merging inserts the quads to preserve the axis sorting so that efficient partitioning during drawing can be performed.