def build(self): data_dir = getattr(self, 'user_data_dir') #get a writable path to save our score self.store = JsonStore(join(data_dir, 'score.json')) # create a JsonScore file in the available location if(not self.store.exists('score')): # if there is no file, we need to save the best score as 1 self.store.put('score', best=1) if platform() == 'android': # if we are on Android, we can initialize the ADs service revmob.start_session('54c247f420e1fb71091ad44a') self.screens = {} # list of app screens self.screens['menu'] = MenuScreen(self) #self the MainApp instance, so others objects can change the screen self.screens['game'] = GameScreen(self) self.root = FloatLayout() self.open_screen('menu') self.sound = SoundLoader.load('res/background.mp3') # open the background music # kivy support music loop, but it was not working on Android. I coded in a different way to fix it # but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat # self.sound.loop = True It # was not working on android, so I wrote the following code: self.sound.play() # play the sound Clock.schedule_interval(self.check_sound, 1) #every second force the music to be playing return self.root
def build(self): data_dir = getattr( self, 'user_data_dir') #get a writable path to save our score self.store = JsonStore(join( data_dir, 'score.json')) # create a JsonScore file in the available location if (not self.store.exists('score') ): # if there is no file, we need to save the best score as 1 self.store.put('score', best=1) if platform( ) == 'android': # if we are on Android, we can initialize the ADs service revmob.start_session('54c247f420e1fb71091ad44a') self.screens = {} # list of app screens self.screens['menu'] = MenuScreen( self ) #self the MainApp instance, so others objects can change the screen self.screens['game'] = GameScreen(self) self.root = FloatLayout() self.open_screen('menu') self.sound = SoundLoader.load( 'res/background.mp3') # open the background music # kivy support music loop, but it was not working on Android. I coded in a different way to fix it # but if fixed, we can just set the loop to True and call the play(), so it'll auto repeat # self.sound.loop = True It # was not working on android, so I wrote the following code: self.sound.play() # play the sound Clock.schedule_interval(self.check_sound, 1) #every second force the music to be playing return self.root
use_ads = True except ImportError: use_ads = False Builder.load_file('gameScreen.kv') Builder.load_file('mainMenu.kv') if use_ads: if platform() == 'android': REVMOB_APP_ID = 'android_id' elif platform() == 'ios': REVMOB_APP_ID = 'ios_id' else: REVMOB_APP_ID = 'unknown platform for RevMob' revmob.start_session(REVMOB_APP_ID) class HexTap(App): def __init__(self, **kwargs): super(HexTap, self).__init__(**kwargs) self.difficulty = 1 self.first_run = True self.current_state = 'mainMenu' self.content = BoxLayout() self.main_menu = MainMenu() self.help_menu = HelpMenu() self.game_map = None self.content.add_widget(self.main_menu) self.music = SoundLoader.load('assets/audio/music.ogg') self.soundsOption = True
def start_session(instance): revmob.start_session(REVMOB_APP_ID)