After messing with it more, the show ads is working, but I had the showAdFromTop() in the draw() function and it was getting called 60 times per second, which is what was throwing it off.
I put the showAdFromTop() into the function that changed gameState and it worked perfect.
Once I figure this all out I’m going to write an up to date in depth tutorial on how to implement iAds into your universal project.
For anyone curious, and for future reference for myself here is the lua code that works as universal and iAds showing in the try again screen:
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
function setup()
ast={}
ship=readImage("Space Art:Red Ship")
asteroid=readImage("Space Art:Asteroid Large")
bg=readImage("SpaceCute:Background")
astFreq=1.5
astSpeed=-HEIGHT/114
score=0 -- starting score
timer=0
rectMode(CENTER)
if readLocalData("HS")== nil then
saveLocalData("HS", 0)
end
music("A Hero's Quest:Battle",true,.5)
gameState=0
font("Futura-CondensedExtraBold")
fontSize(HEIGHT/16)
fill(0, 255, 0, 255)
shipX=WIDTH/2
shipY=HEIGHT/4
end
function spawn()
table.insert(ast,vec2(math.random(WIDTH/8,WIDTH-WIDTH/8),HEIGHT+HEIGHT/8))
end
function draw()
if gameState==0 then
sprite(bg,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
text("PLAY",WIDTH/2,HEIGHT/2)
if CurrentTouch.state==BEGAN then
if CurrentTouch.x>WIDTH/2-WIDTH/3 and CurrentTouch.x<WIDTH/2+WIDTH/3
and CurrentTouch.y>HEIGHT/2-HEIGHT/8 and
CurrentTouch.y<HEIGHT/2+HEIGHT/8 then
gameState=1
end
end
end
if gameState==1 then
sprite(bg,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
pushStyle()
text("Score: "..score, WIDTH/2, HEIGHT/1.2)
popStyle()
for a,b in pairs(ast) do
sprite(asteroid,b.x,b.y,WIDTH/4,HEIGHT/4)
b.y=b.y+astSpeed
end
timer=timer+DeltaTime
if timer>astFreq then
spawn()
spawn()
spawn()
timer=0
end
for a,b in pairs(ast) do
if b.y<-HEIGHT/8 then
table.remove(ast,a)
score=score+10
end
end
if CurrentTouch.x <= WIDTH / 2 and CurrentTouch.state ~= ENDED and
CurrentTouch.state ~= CANCELLED then
shipX=shipX-WIDTH/64
end
if CurrentTouch.x>WIDTH/2 and CurrentTouch.state ~= ENDED and
CurrentTouch.state ~= CANCELLED then
shipX=shipX+WIDTH/64
end
sprite(ship,shipX,shipY,WIDTH/12,HEIGHT/10.67)
for a,b in pairs(ast) do
if b.y-HEIGHT/10.667<=shipY+HEIGHT/21.33 and
b.y+HEIGHT/6.4>=shipY-HEIGHT/21.33 and
b.x-WIDTH/8<=shipX+WIDTH/24 and b.x+WIDTH/8>=shipX-WIDTH/24 then
gameState=2
showAdFromTop()
end
end
if shipX-WIDTH/24<0 or shipX+WIDTH/24>WIDTH then
gameState=2
showAdFromTop()
end
end
if gameState==2 then
sprite(bg,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT)
text("RETRY",WIDTH/2,HEIGHT/4)
if score > readLocalData("HS") then
saveLocalData("HS", score)
end
text("Score: "..score, WIDTH/2,HEIGHT/1.2)
text("HighScore: "..readLocalData("HS"),WIDTH/2,HEIGHT/2)
if CurrentTouch.state==BEGAN then
if CurrentTouch.x>WIDTH/2-WIDTH/7.68 and
CurrentTouch.x<WIDTH/2+WIDTH/7.68
and CurrentTouch.y>HEIGHT/4-HEIGHT/16 and
CurrentTouch.y<HEIGHT/4+HEIGHT/16 then
score=0
gameState=0
hideAd()
shipX=WIDTH/2
for i,t in pairs(ast) do ast[i]= nil
end
end
end
end
end