I’ve been looking at this tutorial https://coronalabs.com/blog/2014/07/15/tutorial-implementing-admob-v2/ which has helped me out a lot with ads, but I just can’t get them to show for me. Where exactly should I set everything up using composer? this is what my code look likes now and it just wont show… Could someone help me out with what I’m dong wrong?
local composer = require "composer" local scene = composer.newScene() local GGData = require "GGData" local loadsave = require "loadsave" local ads = require( "ads" ) local bannerAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnnn" --for your iOS banner local interstitialAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnn" --for your iOS interstitial if ( system.getInfo( "platformName" ) == "Android" ) then bannerAppID = "ca-app-pub-4268482669933469/3951033837" --for your Android banner interstitialAppID = "ca-app-pub-nnnnnnnnnnn/nnnnnnnnn" --for your Android interstitial end local adProvider = "admob" local function adListener( event ) end ads.init( adProvider, appID, adListener ) local box = GGData:new("sample") box:set("message", "hello world") box.anotherValue = 0 box:load() local function play(event) composer.gotoScene("gamescene") end local function mainmenu(event) composer.gotoScene("mainmenu") end function scene:create(event) local sceneGroup = self.view myTable = loadsave.loadTable("myTable.json") local bg = display.newImage("bg.png") sceneGroup:insert(bg) bg:translate(-70, 40) ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) local options = { width = 250, height = 100, numFrames = 1, sheetContentWidth = 250, sheetContentHeight = 100, } local imageSheet = graphics.newImageSheet( "image4154.png", options ) local gameoverimage = display.newImage( imageSheet, 1 ) gameoverimage:translate(160, 70) sceneGroup:insert(gameoverimage) local youscored = display.newText("Score", 160, 150, native.systemFont, 30) sceneGroup:insert(youscored) youscored:setFillColor(0,0,0) local scorenumber = display.newText(\_G.score, 160, 190, native.systemFont, 30) sceneGroup:insert(scorenumber) scorenumber:setFillColor(0,0,0) local best = display.newText("Best", 160, 240, native.systemFont, 30) best:setFillColor(0,0,0) sceneGroup:insert(best) local highscore = display.newText(box.anotherValue, 160, 270, native.systemFont, 30) highscore:setFillColor(0,0,0) sceneGroup:insert(highscore) local playagain = display.newText("Play Again", 160, 360, native.systemFont, 30) playagain:addEventListener("tap", play) sceneGroup:insert(playagain) playagain:setFillColor(0,0,0) local endgame = display.newText("End Game", 160, 400, native.systemFontBold, 30) sceneGroup:insert(endgame) endgame:addEventListener("tap", mainmenu) endgame:setFillColor(0,0,0) end function scene:show( event ) local phase = event.phase ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) if "did" == phase then ads.show( "banner", { x=0, y=0, appId=bannerAppID } ) ads.show( "interstitial", { appId=interstitialAppID } ) print( "2: show event, phase did" ) -- remove previous scene's view composer.removeScene( "gamescene" ) end end scene:addEventListener("show", scene) scene:addEventListener("create", scene) return scene
