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

标签 lua admob coronasdk

我构建了一个小的 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/

相关文章:

c++ - C++ 中的 Lua 转储

lua - 语言是 Lua,单词是 "embedded"

path - 如何使用 .lua 导航到上面的目录

android - Google Adview NullPointerException 与 viewpager

unity3d - 如何在 Unity AIP 中从 AdMob 获取价格?

android - AdMob - 创建广告时为 "Invalid or non-existent app url"

variables - lua中的变量_有特殊含义吗?

iphone - 电晕: "build for" menu doesn't include iPhone

ios - Corona SDK - iOS 游戏中心得分错误,小数逗号

scala - Bugsense 返回错误 : "list index out of range"