gpt4 book ai didi

lua - Corona SDK 上的 Admob Interstitial 仅显示一次

转载 作者:行者123 更新时间:2023-12-01 15:38:08 26 4
gpt4 key购买 nike

我构建了一个小的 main.lua 来测试 admobs 的广告,但我的插页式 admob 有问题。

-- The name of the ad provider.
local provider = "admob"

-- Your application ID
local appID = "ca-app-pub-7171907831713303/2674724079"

-- Load Corona 'ads' library
local ads = require "ads"

--------------------------------------------------------------------------------
-- Setup ad provider
--------------------------------------------------------------------------------

-- Create a text object to display ad status
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

-- Set up ad listener.
local function adListener( event )
-- event table includes:
-- event.provider
-- event.isError (e.g. true/false )

local msg = event.response

-- just a quick debug message to check what response we got from the library
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

showAd( "banner" )
else
statusText:setTextColor( 0, 255, 0 )
statusText.text = "Successfully Loaded Ad"
statusText.x = display.contentWidth * 0.5
end
end

-- Initialize the 'ads' library with the provider you wish to use.
if appID then
ads.init( provider, appID, adListener )
end

--------------------------------------------------------------------------------
-- UI
--------------------------------------------------------------------------------

-- initial variables
local sysModel = system.getInfo("model")
local sysEnv = system.getInfo("environment")

-- create a background for the app
local backgroundImg = display.newImageRect( "space.png", display.contentWidth, display.contentHeight )
backgroundImg:setReferencePoint( display.TopLeftReferencePoint )
backgroundImg.x, backgroundImg.y = 0, 0
statusText:toFront()

-- Shows a specific type of ad
showAd = function( adType )
local adX, adY = display.screenOriginX, display.screenOriginY
statusText.text = ""
ads.show( adType, { x=adX, y=adY } )
end

-- if on simulator, let user know they must build for device
if sysEnv == "simulator" then
local font, size = native.systemFontBold, 22
local warningText = display.newText( "Please build for device or Xcode simulator to test this sample.", 0, 0, 290, 300, font, size )
warningText:setTextColor( 255 )
warningText:setReferencePoint( display.CenterReferencePoint )
warningText.x, warningText.y = display.contentWidth * 0.5, display.contentHeight * 0.5
else
-- start with banner ad
showAd( "interstitial" )
end

我已经在我的设备上测试了这个应用程序,当我第一次启动它时一切正常。但在那之后没有显示任何广告。我应该等多久才能看到广告?

可能是什么问题?

最佳答案

因为你只调用了一次。您需要在延迟或任何事件不断发生的循环中调用它。

你必须继续调用 showAd( "interstitial")

关于lua - Corona SDK 上的 Admob Interstitial 仅显示一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20914348/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com