The following method will search through the tile map. If a slot is filled with the value 99
that means the corresponding tile needs to be deleted.
1. Insert a method header named
ClearGems
into thegame
class.Method ClearGems:Int()
2. Start two FOR loops, one for the rows and one for the columns.
For Local r:Int = 1 To rows For Local c:Int = 1 To columns
3. Check if the tile map contains the value
99
.If tileMap[c-1][r-1] = 99 Then
4. If yes, initialize the slot.
tileMap[c-1][r-1] = -1
5. Next, perform a touch check. The current number of columns and rows has each to be multiplied by
64
(the image width). The ID is set to99
.layerGame.TouchCheck(c*64.0, r*64.0, 99)
I'm sure you wondering why we use a touch check. Later, in the
engine
class, we will check inside theOnObjectTouch
method for this ID and then remove the object.6. Close the IF check, both FOR loops, and the method.
Endif Next Next Return 0 End