当我在 main.lua 文件中使用下面的代码时,它会按我想要的方式显示广告。但是当我 在“exitScene”场景部分添加“ads.hide()” (广告停留在每个场景中)时,我在终端“尝试索引全局“广告”(一个零值)”中得到这个错误,我理解因为广告没有显示在模拟器中,但是当我打开应用程序操作我的手机(galaxy s4)时,没有任何按钮响应,它只停留在 main.lua 文件/场景中
local provider = "admob"
local appID = "**********"
local ads = require "ads"
local screenGroup = self.view
local statusText = display.newText( "", 0, 0, native.systemFontBold, 22 )
statusText:setTextColor( 255 )
statusText:setReferencePoint( display.CenterReferencePoint )
statusText.x, statusText.y = display.contentWidth * 0.5, 160
local showAd
local function adListener( event )
local msg = event.response
print("Message received from the ads library: ", msg)
if event.isError then
statusText:setTextColor( 255, 0, 0 )
statusText.text = "Error Loading Ad"
statusText.x = display.contentWidth * 0.5
local screenGroup = self.view
showAd( "banner" )
else
end
end
if appID then
ads.init( provider, appID, adListener )
end
local sysModel = system.getInfo("model")
local sysEnv = system.getInfo("environment")
showAd = function( adType )
local screenGroup = self.view
local adX, adY = display.screenOriginX, 400
statusText.text = ""
ads.show( adType, { x=adX, y=adY } )
end
if sysEnv == "simulator" then
else
local screenGroup = self.view
showAd( "banner" )
end
嗨,我如何关闭或销毁屏幕更改上的“admob”广告?