Danny, thanks for reply…
Here my Sample Code
1.gameTimer
gameTimer = timer.performWithDelay(1000,CallGameTimer,0)
- I have totally three character in my game . they are continuously running in certain area ,suddenly they stop some random area that time player will shoot them and get the score.
function CallFirstCharacter()
----- 1 RunningCode here ----
end
function CallSecondCharacter()
----- 2 RunningCode here ----
end
function CallThirdCharacter()
----- 3 RunningCode here ----
ends
timer1 = timer.performWithDelay(100,CallFirstCharacter,0)
timer2 = timer.performWithDelay(100,CallSecondCharacter,0)
timer3 = timer.performWithDelay(100,CallThirdCharacter,0)
pause timer code here
PauseFunction = function(event)
if event.phase == “ended” then
if gameTimer ~= nil then
timer.pause(gameTimer)
end
if timer1 ~= nil then
timer.pause(timer1)
end
if timer2 ~= nil then
timer.pause(timer2)
end
if timer3 ~= nil then
timer.pause(timer3)
end
end
end
pause:addEventListener(“touch”,PauseFunction)
ResumeFunction = function(event)
if event.phase == “ended” then
if gameTimer ~= nil then
timer.resume(gameTimer)
end
if timer1 ~= nil then
timer.resume(timer1)
end
if timer2 ~= nil then
timer.resume(timer2)
end
if timer3 ~= nil then
timer.resume(timer3)
end
end
end
Resume:addEventListener(“touch”,ResumeFunction)
store = require(“store”)
function storeTransaction( event )
local transaction = event.transaction
if transaction.state == “purchased” then
local alert = native.showAlert(“InAppPurcahse”,“Item was purchased”,{“ok”},onComplete)
elseif transaction.state == “restored” then
elseif transaction.state == “cancelled” then
elseif transaction.state == “failed” then
else
end
store.finishTransaction( transaction )
end
InAppScreenPurchase = function(event)
store.init( storeTransaction )
store.purchase( {“com.Change.NewGun”})
end
PurcahseButInApp:addEventListener(“touch”,InAppScreenPurchase)
After in app purchase all timer will pause automatically.
thanks
[import]uid: 119468 topic_id: 22393 reply_id: 89566[/import]