MichaelStott / KivMob

AdMob support for Kivy
MIT License
143 stars 38 forks source link

how can i access this ads in my code #75

Open arftylmz opened 4 years ago

arftylmz commented 4 years ago

class Game(App): def build(self): self.ads = KivMob("------") self.ads.new_interstitial("-------") self.ads.request_interstitial() return sm def show_interstitial(self): self.ads.request_interstitial() if self.ads.is_interstitial_loaded(): self.ads.show_interstitial() i access with kv file like this on_press: app.show_interstitial() but i want to access this ads fonc, another class ty for help

akgupta0777 commented 4 years ago

I think you have to change your function name because it can override the same function in KivMob module.

And for accessing this function in other classes. Create a init() method in those classes. and make a app object. Like this

def __init__(self,**kwargs):
    super.__init__(**kwargs)
    self.app = App.get_running_app()

Now with the help of this object access the function anywhere in your class Like this

self.app.Show_Interstitial() #or any other 
                # function of App class