This method will create the corresponding image object, set the collision properties for the touch check, and return the object.
CreateTile
to the game
class. The parameters are the x
and y
coordinates of the image object and its tile ID.Method CreateTile:ftObject(x:Int, y:Int, tile:Int = -100)
ftObject
.Local obj:ftObject
tile
is set to -100
, determine a random value ranging from 0
to 6
.If tile = -100 Then tile = Rnd(6)
eng.SetDefaultLayer(layerGame)
We have six gem images on the sprite sheet. The tile
parameter will not only set the object's tag property, but will also set the sprite coordinates.
tile
equals 6
, top it to 5
.If tile = 6 Then tile = 5
tile
parameter, create an image object from the sprite atlas.If tile < 4 Then obj=eng.CreateImage(atlas,tile*64,64,64,64,x*64,y*64) Elseif tile = 4 obj=eng.CreateImage(atlas,0,128,64,64,x*64,y*64) Else obj=eng.CreateImage(atlas,64,128,64,64,x*64,y*64) Endif
circle
. Then, close the method.obj.SetTag(tile) obj.SetRadius(30) obj.SetTouchMode(2) Return obj End
You have created a method that will create a gem sprite for you. If you add more types of gems, then this method has to be modified.
Once gems are removed from the grid, you need to fill it up with new gems. These gems will fall from the top of the grid. The grid will be checked for empty slots (ID = -1)
from the bottom to the top, and from left to right, in each row. Once an empty slot is found in a row, the method will either find a gem that can fall down or create a new one.
3.145.109.8