Hi Bob
Thanks for your help , but I still can not get it work correctly
first , you might made a mistake
rect.height = display.actualContentHeight - adHeight rect.anchorY = 0 rect.y = adHeight
this line :
rect.y = adHeight
should be below like ?
rect.y = display.screenOriginY
but after I fix it , it still not works
here is my source code :
https://dl.dropboxusercontent.com/u/29345465/imgs/AdmobTest.zip
if I set config.lua
width = 600, height = 800,
here is what I get (see screenshoots)
portrait : (not fix :( )
landscape : (seems it works on landscape , I don’t know it’s a coincidence or it’s prospective)
if I set config.lua (width and height changed)
width = 500, height = 1600,
or
width = 500, height = 1500,
here is what I get (see screenshoots)
portrait : (fit perfectly. :lol: , but after I rotate the phone to landscape , will not fit <_< )
landscape : (not fix)
here is my source code :
https://dl.dropboxusercontent.com/u/29345465/imgs/AdmobTest.zip
rect.png :
main.lua :
----- coronasdk version : 2016.2906 ----------------------------- ----- test device : iphone 6s , ipad mini 3---------------------- ----- admob para ------------------------------------------------ display.setDefault("background", 1,0/255, 0/255) local ads = require( "ads" ) local ads\_testMode = true local myID = "ca-app-pub-9829826968851971/0123456789" local targetingParams = { tagForChildDirectedTreatment = true } ----- load rect.png (200x200) ----------------------------------- local rect = display.newImage("rect.png") rect.anchorX = 0 rect.anchorY = 0 rect.x = display.screenOriginX rect.y = display.screenOriginY print(rect.height) ----- output 200 -------- admob event listener ----------------------------------- function adListener( event ) print("ad event handler fire!") if ( event.isError ) then print("ad error: type: "..event.type) elseif(event.phase =="shown") then local adHeight = ads.height() print("ads.height() : ", adHeight) rect.anchorX = 0 rect.anchorY = 0 rect.x = display.screenOriginX rect.y = display.screenOriginY rect.height = display.actualContentHeight - adHeight end end -------initialize admob then show the banner ad ----------------- ads.init( "admob", myID, adListener ) -------I set the banner x to 100 , so I can if the rect perfectly fit ----- ads.show( "banner", { x=display.screenOriginX + 100, y=99999999, targetingOptions=targetingParams, appId=myID ,testMode = ads\_testMode} ) -------- resize , call after orientation changed ----- function resize( event ) print("resize , show admob banner") -------I set the banner x to 100 , so I can if the rect perfectly fit ----- ads.show( "banner", { x=display.screenOriginX+100, y=99999999, targetingOptions=targetingParams, appId=myID ,testMode = ads\_testMode }) end Runtime:addEventListener("resize",resize) -------- end that' all-----------------------------------------
Thanks
Tang