The OnObjectTouch
method is updated as follows:
Method OnObjectTouch:Int(obj:ftObject, touchId:Int) Local xdiff:Float Local ydiff:Float
g.gmMenu
.If g.gameMode = g.gmMenu Then
Select
statement on the object's Tag
property.Select obj.GetTag()
g.btnPlay
(the play button). If yes, then start a new game.Case g.btnPlay g.StartNewGame()
g.btnScore
(the score button). If yes, then show the high-score screen.Case g.btnScore g.ShowScore
g.btnExit
(the exit button). If yes, then exit the app.Case g.btnExit g.eng.ExitApp(True)
Select
statement. After that, play the g.sndSelect
sound and close the IF statement.End g.sndSelect.Play() Endif
g.gmPlay
, that there are no transitions in the game layer, that the touch ID is not 99
, and that justStarted
is not True
.If g.gameMode = g.gmPlay And g.layerGame.GetObjTransCount() = 0 And touchId <> 99 And g.justStarted = False Then
If g.firstTile <> Null Then Get the X/Y distance of the first tile and the current one xdiff = g.firstTile.GetPosX() - obj.GetPosX() ydiff = g.firstTile.GetPosY() - obj.GetPosY()
x
and y
positions.If ((Abs(xdiff)<80.0) And (Abs(ydiff)<2.0)) Or ((Abs(ydiff)<80.0) And (Abs(xdiff)<2.0)) Then
g.secondTile = obj
If (g.CountGems(g.firstTile, g.secondTile)>1) Or (g.CountGems(g.secondTile, g.firstTile)>1) Then
g.SetSlotTile(g.GetSlotX(g.secondTile), g.GetSlotY(g.secondTile),-1) g.SetSlotTile(g.GetSlotX(g.firstTile), g.GetSlotY(g.firstTile),-1)
g.firstTile.CreateTransPos(g.secondTile.GetPosX(),g.secondTile.GetPosY(),300,False,99) g.secondTile.CreateTransPos(g.firstTile.GetPosX(),g.firstTile.GetPosY(),300,False,99) Endif
g.secondTile = Null g.firstTile = Null
g.selector.SetPos(0, 0) g.selector.SetVisible(False) Else
g.firstTile = Null g.selector.SetPos(0, 0) g.selector.SetVisible(False)
g.sndFalse
sound.g.sndFalse.Play() Endif Else
g.firstTile = obj g.selector.SetPos(obj.GetPosX(), obj.GetPosY()) g.selector.SetVisible(True) Endif Endif
g.gmPlay
and the touch ID is 99
, then raise the value of score
by 100
, spawn an explosion, and remove the tile.If g.gameMode = g.gmPlay And touchId = 99 Then g.score += 100 SpawnExplosion(7,obj.GetPosX(), obj.GetPosY()) obj.Remove() Endif
g.justStarted = False
Back
button was selected.If obj.GetTag() = g.btnBack Then g.ShowMenu() Return 0 End
Now that we have handled the touch events, all buttons are functional, and you can start a new game. You can also select the first two tiles. We still need to handle the transition and the winning conditions of the game, so let's go further.
18.220.96.214