def _load_background_image(self): if self.levelMap == "lvlcustom": # if custom image, load new backgroundImage = resources.load_custom_image() elif self.levelMap == "background": backgroundImage = resources.background["background"] else: backgroundImage = resources.background[str(self.levelMap)] return cocos.sprite.Sprite(backgroundImage)
def _load_background_image(self): if (self.levelMap == "lvlcustom"): # if custom image, load new backgroundImage = resources.load_custom_image() elif (self.levelMap == "background"): backgroundImage = resources.background["background"] else: backgroundImage = resources.background[str(self.levelMap)] return cocos.sprite.Sprite(backgroundImage)
def initialise(self): self.font_title['font_name'] = _font_ self.font_title['font_size'] = 72 self.font_item['font_name'] = _font_ self.font_item['font_size'] = 35 self.font_item_selected['font_name'] = _font_ self.font_item_selected['font_size'] = 41 self.menu_anchor_x = cocos.menu.CENTER self.menu_anchor_y = cocos.menu.CENTER self.items = [] image_lvl1 = resources.background["lvl1"] lvl1 = modmenu.ImageMenuItem(image_lvl1, lambda: self.on_start(1)) Back = cocos.menu.MenuItem('Back', self.on_quit) Back.y -= 30 image_lvl2 = resources.background["lvl2"] lvl2 = modmenu.ImageMenuItem(image_lvl2, lambda: self.on_start(2)) mapBuilderActivated = "nobuilder" try: mapBuilderActivated = sys.argv[1] except: mapBuilderActivated = "nobuilder" if(mapBuilderActivated == "builder"): MapBuilder = cocos.menu.MenuItem('MapBuilder', self.on_mapBuilder) MapBuilder.y -= 20 if( os.path.isfile(os.path.join( os.path.dirname( os.path.abspath(__file__)), "assets/lvlcustom.png"))): customImage = resources.load_custom_image() lvl1.scale = 0.18 lvl1.y = 30 self.items.append(lvl1) lvl2.scale = 0.18 lvl2.y -= 150 self.items.append(lvl2) customItem = ( modmenu.ImageMenuItem( customImage, lambda: self.on_start("custom"))) customItem.scale = 0.22 customItem.y -= 300 self.items.append(customItem) if(mapBuilderActivated == "builder"): MapBuilder.y -= 340 Back.y -= 20 Back.y -= 320 # custom map has to be positioned correctly in Menu else: lvl1.scale = 0.28 lvl1.y = 0 self.items.append(lvl1) lvl2.scale = 0.28 lvl2.y -= 300 self.items.append(lvl2) if(mapBuilderActivated == "builder"): MapBuilder.y -= 320 Back.y -= 20 Back.y -= 300 if(mapBuilderActivated == "builder"): self.items.append(MapBuilder) self.items.append(Back) width, height = director.get_window_size() self.create_menu(self.items)