To count the matching tiles, follow the ensuing steps:
1. Add the method
CountGems
into thegame
class. The parameters are the first and second object.Method CountGems:Int(obj1:ftObject, obj2:ftObject)
2. Define four local INT variables that store the
x
andy
positions of the objects.Local x1:Int Local y1:Int Local x2:Int Local y2:Int
3. Now define four INT variables that store the number of gems that were found.
Local gemCountX1:Int Local gemCountY1:Int Local gemCountX2:Int Local gemCountY2:Int
4. Get the slot positions of both objects.
x1 = GetSlotX(obj1) y1 = GetSlotX(obj1) x2 = GetSlotX(obj2) y2 = GetSlotY(obj2)
5. Retrieve the gem count of the first object. The position is the one of the second object, as that is where the first object is to be moved.
gemCountX1 = CheckGemsX(x2, y2, obj1.GetTag()) gemCountY1 = CheckGemsY(x2, y2, obj1.GetTag())
6. Do the opposite for the second object.
gemCountX2 = CheckGemsX(x1, y1, obj2.GetTag()) gemCountY2 = CheckGemsY...