Hi Rob
thanks for the reply, my code for main.lua. will review the logs and update as well…
-----------------------------------------start ------------------------------------------------
– req and initialize google analytic
local ga = require(“plugin.googleAnalytics”)
ga.init( “Ready Steady Squeeze”, “UA-86396024-1” )
–end ga
–init and start physics
local physics = require( “physics” )
physics.start()
physics.setGravity( 0, 0 )
–end physics
– req corona ads
local coronaAds = require( “plugin.coronaAds” )
local interstitialPlacement = “corona-int”
– end corona ads
–load sounds
local readySound = audio.loadSound(“ready.wav”)
local playSound = audio.loadSound(“alert.wav”)
–end sounds
– Initialize variables
local playerOne
local playerComputer
local playerTwo
– Set up display groups
local backGroup = display.newGroup() – Display group for the background image
local mainGroup = display.newGroup() – Display group for game play elements
local uiGroup = display.newGroup() – Display group for UI objects like the score
– Hide the status bar
display.setStatusBar( display.HiddenStatusBar )
– Load the background
local background = display.newImageRect( backGroup, “background.png”, 800, 1400 )
background.x = display.contentCenterX
background.y = display.contentCenterY
– laod the transparent layer
local transparentLayer = display.newImageRect( mainGroup,“transparent.png”, 800, 1400 )
transparentLayer.x = display.contentCenterX
transparentLayer.y = display.contentCenterY
transparentLayer.isActive = false
transparentLayer.isVisible = false
– load the start btn
local startBtn = display.newImageRect(mainGroup, “start.png”, 800, 100)
startBtn.x = display.contentCenterX
startBtn.y = display.contentCenterY
– load the retry button
local retryBtn = display.newImageRect(mainGroup,“retry.png”, 800, 100)
retryBtn.x = display.contentCenterX
retryBtn.y = display.contentCenterY
retryBtn.isActive = false
retryBtn.isVisible = false
– Display lives and score
playerOneText = display.newText( uiGroup, “Player One Wins!!”, display.contentCenterX, display.contentHeight - 50, native.systemFont, 56 )
playerTwoText = display.newText( uiGroup, “Player Two Wins!!”, display.contentCenterX, 50, native.systemFont, 56 )
playerTwoText:rotate(180)
playerOneText:setTextColor(0,0,128)
playerTwoText:setTextColor(0,0,128)
playerOneText.isVisible = false
playerTwoText.isVisible = false
– Corona Ads listener function
local function adListener( event )
– Successful initialization of Corona Ads
if ( event.phase == “init” ) then
– Show an ad
--coronaAds.show( bannerPlacement, false )
print(“corona ads initialized”)
coronaAds.show( interstitialPlacement, true )
end
end
– custom sound functions
local function playMainSound()
transparentLayer.isVisible = true
transparentLayer.isActive = true
audio.play( playSound, { duration=2000})
end
local function playMainSoudCheck()
print(“in play main sound random check”)
local randomTime = math.random(100,3000)
print(randomTime)
timer.performWithDelay(randomTime, playMainSound)
end
local function playReadySound()
audio.play( readySound, { duration=3000, onComplete=playMainSoudCheck} )
transparentLayer.isActive = true
end
– end sound functions
– event function for start button
local function startGame()
transparentLayer.isActive = false
playerOneText.isVisible = false
playerTwoText.isVisible = false
startBtn.isVisible = false
print(“start button touched”)
ga.logEvent( “userAction”, “start”, “Start Button” )
timer.performWithDelay( 2000, playReadySound)
end
– end start button function
– event function for retry button
local function retryGame()
– log a ga event
ga.logEvent( “userAction”, “Retry”, “Retry Button” )
– calling corona ad listener function when user retry to play again
coronaAds.init( “0353baa6-25e4-42cc-8ae4-0f408983b8de”, adListener )
– display hide buttons
startBtn.isVisible = true
startBtn.isActive = true
retryBtn.isVisible = false
retryBtn.isActive = false
playerOneText.isVisible = false
playerTwoText.isVisible = false
transparentLayer.isActive = false
transparentLayer.isVisible = false
– social plugin
–native.showPopup( “social”,
--{
– service = “twitter”,
– message = “Hi there!”,
– url = "http://www.coronalabs.com",
--})
–
end
– end retry button function
– calculate result
local function checkResult(event)
local touchValue = 0
if ( event.phase ==“began”) then
if (event.y > display.contentCenterY) then
print(" player 1 wins")
transparentLayer.isActive = false
playerOneText.isVisible = true
retryBtn.isVisible = true
retryBtn.isActive = true
elseif (event.y < display.contentCenterY) then
print(" player 2 wins")
transparentLayer.isActive = false
playerTwoText.isVisible = true
retryBtn.isVisible = true
retryBtn.isActive = true
end
elseif ( “ended” == phase or “cancelled” == phase ) then
print(“transparent layer touched and ended”)
end
end
– end calculate result
– start, retry and touch event listeners
startBtn:addEventListener( “tap”, startGame)
retryBtn:addEventListener(“tap”, retryGame)
transparentLayer:addEventListener(“touch”, checkResult)
------------------------------------------- end ----------------------------------------------