DrMoriarty / godot-applovin-max

AppLovinMax plugin for godot engine.
27 stars 7 forks source link

Global ads manager #9

Closed AbdulkarimAhmad closed 3 years ago

AbdulkarimAhmad commented 3 years ago

hi there am trying to make a global ad manager so I can load ads and remove it in any scene so it not crash if the current scene die . I have the game scene that autoload and work globally so i include the call method in it

Screen Shot 2021-08-17 at 4 28 37 PM

func _ready():
    if CheckIfExist(): # chech if save game exist
        LoadGame()
    root = get_tree().get_root() # get the root of the application 
    progressBar = get_node("CanvasLayer/TextureProgress")
    get_node("CanvasLayer/TextureRect").visible = false
    progressBar.visible = false

func loadBanner() :
    applovin_max.loadBanner("449d3e1f299a6c41",false ,self.get_instance_id())

func loadInetr() :
    applovin_max.loadInterstitial("c2388c98f3bad91f", self.get_instance_id())

func removeBanner() :
    if applovin_max.removeBanner("449d3e1f299a6c41") :
        print("remove***")
    elif applovin_max.hideBanner("449d3e1f299a6c41") :
        print("hide****")
    else :
        print("not remove and not hide")

func _on_banner_loaded(id: String):
    applovin_max.showBanner(id)

func _on_interstitial_loaded(id: String) :
    applovin_max.showInterstitial(id)

and its work the app not crash anymore on iOS but got 1 issue whenever I call the ads it work above the current scene I tried to stop the scene until the ads finish but couldn't find way to do it is there a way to make the current scene wait the ads until finish before it start

DrMoriarty commented 3 years ago

If you are talking about interstitial ads, they have _on_interstitial_close callback. You may pause your current scene before showInterstitial and unpause it when _on_interstitial_close appears.

AbdulkarimAhmad commented 3 years ago

that's completely worked thanks