0 votes

Hello guys. I have this issue:

First of all i have a singleton variable:

    extends Node

    var admob = null

The name of the script of singleton variable is: ad.

Also, i have a main scene named World that with my basic game code i have in this script of the World's Node and the following part of code:

var isReal = false
var isTop = true
var adBannerId = "ca-app-pub-3940256099942544/6300978111" 
var debug = null
var isbieunguloaded = false
var istrunggianloaded = false

func _ready():
    if(Engine.has_singleton("AdMob")):
        ad.admob = Engine.get_singleton("AdMob")
        ad.admob.init(isReal, get_instance_id())
        loadBanner()
    debug = get_node("Pause")
    get_tree().connect("screen_resized", self, "onResize")

func loadBanner():
    if ad.admob != null:
        ad.admob.loadBanner(adBannerId, isTop)

func _on_admob_network_error():
    debug.text = "Network Error"
    if(Engine.has_singleton("AdMob")):
        ad.admob = Engine.get_singleton("AdMob")
        ad.admob.init(isReal, get_instance_id())
        loadBanner()

func _on_admob_ad_loaded():
    get_node("Pause").set_disabled(false)

func onResize():
    if ad.admob != null:
        ad.admob.resize()

################################ PAUSE BUTTON:
func _on_Pause_pressed():
    if ad.admob == null:
        ad.admob.showBanner()
    get_tree().paused=not get_tree().paused
    $PauseScene.show()
    pass 

When someone press the Pause button, then he can see the Pause scene. The Pause scene has 3 buttons: 1) Resume, 2) Again and 3)Quit. The code parts of Resume and Again buttons are the followings:

func _on_Again_pressed():
    if ad.mob !=null:
        ad.admob.hideBanner()
....
....
...
...

func _on_Resume_pressed():
    if ad.mob !=null:
        ad.admob.hideBanner()
...
...
...
...

The point is that when i export my game on my adnroid device then i can see the banner all the time during the gameplay. I want seeing the banner when i press the Pause button and hide the banner when i press the Resume or the Again button. What's the wrong here?

Thank you in advance.

in Engine by (218 points)

maybe because its called loadBanner() on the _ready():
it show ad since that

maybe need to place that loadBanner() on onPause_pressed():

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.