This method will create the corresponding image object, set the collision properties for the touch check, and return the object.
1. Add the method
CreateTile
to thegame
class. The parameters are thex
andy
coordinates of the image object and its tile ID.Method CreateTile:ftObject(x:Int, y:Int, tile:Int = -100)
2. Define a local object of the type
ftObject
.Local obj:ftObject
3. If
tile
is set to-100
, determine a random value ranging from0
to6
.If tile = -100 Then tile = Rnd(6)
4. Set the game layer as the default layer.
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.5. If
tile
equals6
, top it to5
.If tile = 6 Then tile = 5
6. Depending on the
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...