尝试对上值'hudGroup'进行索引(它的值为nil)。

我已经使用了Banner和Inneractive Admob,但出现了错误。但只使用Banner时没有索引错误。这个问题出现在进入下一个场景时。

local appID = "ca-app-pub-9490586669956065/9942080439"
local appIDIN = "ca-app-pub-9490586669956065/2418813633"
local ads = require("ads")
local t

local function adListener(event)
    local msg = event.response
    print(msg)
    if event.phase == "loaded" then
    end

    if event.isError then
    end
end

ads.init("admob", appID, adListener)
ads.init("admob", appIDIN, adListener)
local function showBanner()
    ads.show("banner", {x = 2, y = display.viewableContentHeight-5, appID = "ca-app-pub-9490586669956065/9942080439",testMode = true})
end
local function randomDelay()
    return math.random(12000)
end
local function onTimer()
    ads.show( "interstitial", { x=0, y=0 ,appID = "ca-app-pub-9490586669956065/2418813633", testMode = true})
end

local hudGroup = display.newGroup()
timer.performWithDelay( randomDelay(), onTimer, 1)
timer.performWithDelay(50, showBanner, 1)
点赞
用户3803880
用户3803880

hudGroup 是一个本地变量。当你切换场景时,它的引用被销毁了。要么把 hudGroup 变成全局变量,要么根本不使用广告组。

2014-12-11 05:28:44