Advertisement
Guest User

Untitled

a guest
Oct 26th, 2017
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1.  
  2. --[[--- INITIAL VALUES -----]]
  3. display.setStatusBar( display.HiddenStatusBar )
  4. background = display.newImageRect( "background.png", display.contentWidth, display.contentHeight+100 )
  5. background.x = display.contentCenterX
  6. background.y = display.contentCenterY
  7. local physics = require "physics"
  8. local btn = display.newImageRect("button.png",150,150)
  9. local menuIcon = display.newImageRect( "menu.png", 60, 60 )
  10. menuIcon.x = display.contentCenterX-120
  11. menuIcon.y = display.contentCenterY+240
  12. local playsound = display.newImageRect( "playsound.png", 50, 50)
  13. playsound.x = display.contentCenterX + 90
  14. playsound.y = display.contentCenterY - 260
  15. local stopsound = display.newImageRect( "stopsound.png", 50, 50)
  16. stopsound.x = display.contentCenterX + 140
  17. stopsound.y = display.contentCenterY - 260
  18. -- Trying to create an asteriod Shower
  19.  
  20. btn.x = math.random( 1,150 )
  21. btn.y = -125
  22. transition.to(btn, {
  23. x = math.random( 150,300 ),
  24. y = math.random( 700,800 ),
  25. time = 5000,
  26. })
  27. --[[
  28. for i=1,10 do
  29.  
  30.  
  31. if btn.x >= 150 and btn.y >= 700 then
  32. btn.x = math.random( 1,150 )
  33. btn.y = -125
  34. transition.to(btn, {
  35. x = math.random( 150,300 ),
  36. y = math.random( 700,800 ),
  37. time = 5000,
  38. })
  39.  
  40.  
  41. end
  42. end
  43. ]]
  44. --
  45. --[[
  46. btn.x = display.contentWidth/2
  47. btn.y = display.contentHeight/2
  48. ]]
  49.  
  50.  
  51. amountOfTimeYouClicked = 0
  52. testText = display.newText( amountOfTimeYouClicked, display.contentWidth/2, display.contentHeight/2 , "spaceage.ttf", 30 )
  53. testText:setFillColor( 250,223,0 )
  54. test1Text = display.newText( "Clicks ", display.contentWidth/2, display.contentHeight/6 , "SPACEBAR.ttf", 20 )
  55. test1Text.x = display.contentCenterX/2.5
  56. test1Text.y = display.contentCenterY-260
  57. testText.x = display.contentCenterX-110
  58. testText.y = display.contentCenterY-235
  59. -- audio
  60.  
  61. local sndTouch = audio.loadSound("metal-clash.wav")
  62. local sndBackground = audio.loadStream( "backgroundmusic.ogg")
  63.  
  64.  
  65. local function audioloop()
  66. if audio.isChannelActive(2) == true then
  67. audio.resume()
  68.  
  69.  
  70. else
  71. audio.play(sndBackground, {channel = 2, loop = -1})
  72. end
  73. end
  74. playsound:addEventListener( "touch", audioloop)
  75.  
  76.  
  77.  
  78. local function stopaudioloop()
  79.  
  80. audio.pause()
  81.  
  82. end
  83. stopsound:addEventListener( "touch", stopaudioloop)
  84.  
  85. local function pushBtn(event)
  86. if event.phase == "began" then
  87.  
  88. amountOfTimeYouClicked = amountOfTimeYouClicked + 1
  89. print( amountOfTimeYouClicked )
  90. testText.text = tostring(amountOfTimeYouClicked)
  91. audio.play(sndTouch)
  92. -- Makes Asteriod Rotate
  93.  
  94. transition.to( btn, { rotation=-45, time=500, transition=easing.inOutCubic } )
  95.  
  96. transition.to( btn, { rotation=90, time=500, transition=easing.inOutCubic } )
  97.  
  98. if btn.rotation == -45 then
  99. transition.to(btn, {rotation = 90, time = 500, transition=easing.inOutCubic})
  100.  
  101. elseif btn.rotation == 90 then
  102. transition.to( btn, { rotation=-45, time=500, transition=easing.inOutCubic } )
  103.  
  104.  
  105. end
  106.  
  107. ---
  108. end
  109. end
  110. btn:addEventListener( "touch", pushBtn )
  111.  
  112. local settings = display.newImageRect("gear.png", 65 , 65)
  113. settings.x = display.contentCenterX + 120
  114. settings.y = display.contentCenterY+240
  115. local resetBtn = display.newImageRect("reset.png", 65, 65)
  116. resetBtn.x = display.contentCenterX
  117. resetBtn.y = display.contentCenterY+235
  118.  
  119.  
  120. local function resetingBtn(event)
  121.  
  122. if event.phase == "began" then
  123. print( 0 )
  124. testText.text = 0
  125. amountOfTimeYouClicked = testText.text
  126. end
  127. end
  128.  
  129. resetBtn:addEventListener( "touch", resetingBtn)
  130.  
  131.  
  132.  
  133.  
  134. -- Trying to make a Asteriod Wrap around the Screen
  135. --[[
  136.  
  137. -- Makes Asteriod Rotate
  138. btn.rotation = -45
  139. local reverse = 1
  140.  
  141. local function rockRect()
  142. if ( reverse == 0 ) then
  143. reverse = 1
  144. transition.to( btn, { rotation=-45, time=500, transition=easing.inOutCubic } )
  145. else
  146. reverse = 0
  147. transition.to( btn, { rotation=90, time=500, transition=easing.inOutCubic } )
  148. end
  149. end
  150.  
  151. timer.performWithDelay( 600, rockRect, 0 )
  152.  
  153. ---
  154.  
  155. ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement