Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function game(object, event)
- if(event.phase == "began") then
- if(checkForMatch == false and secondSelect == 0) then
- --Flip over first button
- buttonCover[object.number].isVisible = false;
- print(object.myName, "first button name")
- lastButton = object
- checkForMatch = true
- elseif(checkForMatch == true) then
- if(secondSelect == 0) then
- --Flip over second button
- buttonCover[object.number].isVisible = false;
- secondSelect = 1;
- --If buttons do not match, flip buttons over
- if lastButton.myName ~= object.myName then
- if score.scoreAmount >= 5 then
- score:subPoints(5)
- end
- audio.play(clickWrong, {channel=2})
- matchText.text = "Match Not Found!";
- timer.performWithDelay(1250, function()
- matchText.text = " ";
- checkForMatch = false;
- secondSelect = 0;
- buttonCover[lastButton.number].isVisible = true;
- buttonCover[object.number].isVisible = true;
- end, 1)
- --If buttons DO match, remove buttons
- elseif(lastButton.myName == object.myName) then
- score:addPoints(50)
- audio.play(clickRight, {channel=2})
- matchText.text = "Match Found!";
- timer.performWithDelay(1250, function()
- matchText.text = " ";
- checkForMatch = false;
- secondSelect = 0;
- lastButton:removeSelf();
- object:removeSelf();
- buttonCover[lastButton.number]:removeSelf();
- buttonCover[object.number]:removeSelf();
- buttonCounter = buttonCounter - 2
- print("total", buttonCounter)
- end, 1)
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement