Advertisement
Hendrix000007

flipping buttons

Sep 5th, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1.     function game(object, event)
  2.                     if(event.phase == "began") then            
  3.                         if(checkForMatch == false and secondSelect == 0) then
  4.                             --Flip over first button
  5.                             buttonCover[object.number].isVisible = false;
  6.                             print(object.myName, "first button name")
  7.                             lastButton = object
  8.                             checkForMatch = true           
  9.                         elseif(checkForMatch == true) then
  10.                             if(secondSelect == 0) then
  11.                                 --Flip over second button
  12.                                 buttonCover[object.number].isVisible = false;
  13.                                 secondSelect = 1;
  14.                                 --If buttons do not match, flip buttons over
  15.                                 if lastButton.myName ~= object.myName then
  16.                                     if score.scoreAmount >= 5 then
  17.                                         score:subPoints(5)
  18.                                     end
  19.                                     audio.play(clickWrong, {channel=2})
  20.                                     matchText.text = "Match Not Found!";
  21.                                     timer.performWithDelay(1250, function()                    
  22.                                         matchText.text = " ";
  23.                                         checkForMatch = false;
  24.                                         secondSelect = 0;
  25.                                         buttonCover[lastButton.number].isVisible = true;
  26.                                         buttonCover[object.number].isVisible = true;
  27.                                     end, 1)                
  28.                                 --If buttons DO match, remove buttons
  29.                                 elseif(lastButton.myName == object.myName) then
  30.                                         score:addPoints(50)
  31.                                         audio.play(clickRight, {channel=2})
  32.                                         matchText.text = "Match Found!";
  33.                                         timer.performWithDelay(1250, function()                    
  34.                                         matchText.text = " ";
  35.                                         checkForMatch = false;
  36.                                         secondSelect = 0;
  37.                                         lastButton:removeSelf();
  38.                                         object:removeSelf();
  39.                                         buttonCover[lastButton.number]:removeSelf();
  40.                                         buttonCover[object.number]:removeSelf();
  41.                                         buttonCounter = buttonCounter - 2
  42.                                         print("total", buttonCounter)
  43.                                     end, 1)
  44.                                    
  45.                                 end            
  46.                             end        
  47.                         end
  48.                     end
  49.                 end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement