Hi how can i close or destroy a “admob” ad on screen change ? its staying on the screen even if i go to a other .lua file ?
-- Create a text object to display ad status local screenGroup = self.view 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 local screenGroup = self.view showAd( "banner" ) else --efter add 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") -- Shows a specific type of ad showAd = function( adType ) local screenGroup = self.view local adX, adY = display.screenOriginX, 400 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 else local screenGroup = self.view -- start with banner ad showAd( "banner" ) end
-Kevin