Any idea why this always crashes on Android device and never on iPhone or Simulator?
Code:
system.setIdleTimer( false )
background = display.newImage(“background.png”, true)
background.x = display.contentWidth/2
background.y = display.contentHeight/2
background.alpha = 0.5
speed = 40
– Main screen title
mainTitle = display.newText(“Guitar Speed Trainer”, 0, 0, “Tempus Sans ITC”, 32)
mainTitle:setTextColor( 200,0, 0)
mainTitle.x = display.contentWidth/2
mainTitle.y = 50
underTitle = display.newText(“Free edition”, 0, 0, “Tempus Sans ITC”, 22)
underTitle:setTextColor( 50,255, 50)
underTitle.x = display.contentWidth/2
underTitle.y = 100
speedLabel = display.newText(speed, 0, 0, native.systemFont, 100)
speedLabel:setTextColor( 255,255, 255)
speedLabel.x = display.contentWidth/2
speedLabel.y = display.contentHeight/2
startStopButton = display.newText(“Start”, 0, 0, native.systemFont, 50)
startStopButton:setTextColor( 255,255, 255)
startStopButton.x = display.contentWidth/2
startStopButton.y = display.contentHeight - 100
instructionButton = display.newText(“Instructions”, 0, 0, “Tempus Sans ITC”, 36)
instructionButton:setTextColor( 200,0,0)
instructionButton.x = display.contentWidth/2
instructionButton.y = display.contentHeight - 40
local tickSound = audio.loadSound( “tick.mp3” )
function tick()
metronomeTimer = timer.performWithDelay(60000/speedLabel.text, tick, 1)
audio.play( tickSound )
end
function startMetronome()
metronomeTimer = timer.performWithDelay(60000/speed, tick, 1)
increaseTimer = timer.performWithDelay(5000, increaseSpeed, 0)
end
function stopMetronome()
speed = 40
timer.cancel(increaseTimer)
timer.cancel(metronomeTimer)
speedLabel.text = speed
end
function startStop()
if (startStopButton.text == “Start”) then
startMetronome()
startStopButton.text = “Stop”
else
stopMetronome()
startStopButton.text = “Start”
end
end
function increaseSpeed()
speed = speed + 1
speedLabel.text = speed
if (speed == 209) then stopMetronome() end
end
function instructions()
if (instructionButton.text == “Close”) then
native.cancelWebPopup()
instructionButton.text = “Instructions”
else
local options = {baseUrl=system.ResourceDirectory}
native.showWebPopup(0,0, display.contentWidth, display.contentHeight - 70, “instructions.html”, options )
instructionButton.text = “Close”
end
end
instructionButton:addEventListener( “tap”, instructions )
startStopButton:addEventListener( “tap”, startStop )
local ads = require(“ads”)
– Example for inmobi:
ads.init( “inmobi”, “4028cb1334ef46a90135667e2d4213bf” )
– iPhone, iPod touch, iPad
ads.show( “banner320x48”, { x=0, y=0, interval=5, testMode=false } ) [import]uid: 31793 topic_id: 22178 reply_id: 322178[/import]