【发布时间】:2015-01-06 17:22:01
【问题描述】:
-- 我的 build.settings 中的代码
settings =
{
orientation =
{
default = "landscapeRight",
supported = { "landscapeLeft", "landscapeRight" },
},
android =
{
versionCode = "11"
},
androidPermissions =
{
"android.permission.INTERNET",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.READ_PHONE_STATE",
},
build =
{
neverStripDebugInfo = true
},
plugins =
{
-- key is the name passed to Lua's 'require()'
["CoronaProvider.ads.admob"] =
{
-- required
publisherId = "com.coronalabs",
},
},
}
-- 我的 main.lua 中的代码
provider = "admob"
appID = "ca-app-pub-XXX/XXX"
AD_TYPE = "interstitial"
-- MY HomeScreen.lua 中的代码
local adsObject = require ("ads")
local toast = require ("toast")
local function adListener( event )
local msg = event.response
toast.new("Event Msg: "..msg, 2000)
print("Message received from the ads library: ", msg)
local statusText = display.newText( "", 0, 0, native.systemFontBold, 22 )
statusText:setTextColor(153, 0, 51)
statusText.x, statusText.y = display.contentWidth * 0.5, 160
if event.isError then
IS_ADD_INIT = false
toast.new("--FALSE--", 2000)
statusText.text = "Error: "..msg;
else
toast.new("--TRUE--", 2000)
IS_ADD_INIT = true
statusText.text = "Success: "..msg;
adsObject.show( AD_TYPE , { x=centerX, y=centerY } )
end
end
function scene:enterScene( event )
local group=self.view
if appID then
adsObject.init( provider, appID, adListener )
else
toast.new("NO APP ID", 2000)
end
end
请帮忙。 我无法使用上述代码加载广告。
我的 adListener(event) 永远不会被调用。
请纠正我!
我也可以使用我将在 main.lua 中定义的adsObject 的全局引用
【问题讨论】: