def on_activated(self):
     if self.label == 'New game':
         background = game.layers.ImageLayer.ImageLayer(
             'resources/img/back.jpg')
         level_scene = cocos.scene.Scene(background)
         level_scene.add(menu.MenuCreator.MenuCreator.create_level_menu())
         cocos.director.director.replace(SplitColsTransition(level_scene))
     elif self.label == 'Exit':
         music_player.delete()
         cocos.director.director.terminate_app = True
     elif self.label == 'Level 1':
         game_scene = Level1.get_game_scene()
         cocos.director.director.replace(FadeTRTransition(game_scene))
     elif self.label == 'Level 2':
         game_scene = Level2.get_game_scene()
         cocos.director.director.replace(FadeTRTransition(game_scene))
示例#2
0
 def on_host_game(self):
     """ """
     playLayer = self.getPlayLayer()
     gameInstance = GameServer.GameServer(playLayer)
     cocos.director.director.replace(
         FadeTRTransition(gameInstance.get_scene(), 2))
     gameInstance.start()
示例#3
0
 def start(self):
     """ """
     cocos.director.director.replace(FadeTRTransition(
         self.get_scene(), 2))
     self.game_layer.do(CommonLayers.PlayLayerAction())
     self.game_layer.do(CommonLayers.InteractivePlayLayerAction())
     self.game_layer.addPlayer(CommonLayers.PlayLayer.ownID)
示例#4
0
 def start_game(
     self
 ):  # Starts the game and hides the cursor so as to not block the view of bacon
     game_instance = game.Game()
     cocos.director.director.replace(
         FadeTRTransition(game_instance.get_scene(), 2))
     self.window.set_mouse_visible(False)
示例#5
0
 def on_join_game(self):
     """ """
     self.clientLayer = self.makeClientLayer()
     scene = cocos.scene.Scene(self.clientLayer)
     cocos.director.director.replace(FadeTRTransition(scene, 2))
     self.clientLayer.start(self, self.host, self.port)
     self.clientLayer.setNickname(self.nickname)
示例#6
0
 def start(self, host, port):
    """ """
    cocos.director.director.replace(FadeTRTransition(
        self.get_scene(), 2))
    self.game_layer.do(GameChatClient.GameChatClientNetworkAction(
         host, port))
    self.game_layer.do(CommonLayers.InteractivePlayLayerAction())
    self.game_layer.addPlayer(CommonLayers.PlayLayer.ownID)
示例#7
0
 def Join_game(self):
     ui_layer = UILayer(self)
     player_layer = Playerlayer()
     player_layer.do(PlayLayerAction())
     player_layer.addplayer()
     player_layer.addVillain()
     ui_layer.add(player_layer)
     main_play_scene = cocos.scene.Scene(ui_layer)
     cocos.director.director.replace(FadeTRTransition(main_play_scene, 2))
示例#8
0
 def updatelives(self):
     self.numLives = self.numLives - 1
     if self.numLives == 2:
         self.heart3.kill()
     if self.numLives == 1:
         self.heart2.kill()
     if self.numLives == 0:
         self.heart1.kill()
     if self.numLives < 0:
         cocos.director.director.replace(
             FadeTRTransition(self.game.get_menu_scene(), 2))
示例#9
0
 def on_play(self):
     global disconnect
     disconnect = 1
     try:
         shutil.rmtree('dest')
     except FileNotFoundError:
         pass
     try:
         os.mkdir('dest')
     except OSError:
         pass
     director.replace(FadeTRTransition(choose_layer, duration=2))
示例#10
0
 def on_start():
     global text1, text2
     if os.path.isfile('files/blue_bot.py'):
         if os.path.isfile('files/red_bot.py'):
             main.ConnectionClass.connect_to_tank1(0)
             main.ConnectionClass.connect_to_tank2(0)
             main.ConnectionClass.connect_both_tanks()
             director.replace(FadeTRTransition(main.scene))
         else:
             text1 = 'Ошибка при считывании файла. Загрузите файл еще раз.'
     else:
         text2 = 'Ошибка при считывании файла. Загрузите файл еще раз.'
def game_over():
    w, h = cocos.director.director.get_window_size()
    layer = cocos.layer.Layer()
    text = cocos.text.Label('Game Over',
                            position=(w * 0.5, h * 0.5),
                            font_name='Oswald',
                            font_size=72,
                            anchor_x='center',
                            anchor_y='center')
    layer.add(text)
    scene = cocos.scene.Scene(layer)
    new_scene = FadeTRTransition(mainmenu.new_menu())
    func = lambda: cocos.director.director.replace(new_scene)
    scene.do(ac.Delay(3) + ac.CallFunc(func))
    return scene
示例#12
0
 def start(self):
    """ """
    cocos.director.director.replace(FadeTRTransition(
        self.get_scene(), 2))
    self.game_layer.do(GameChatServer.GameChatServerNetworkAction())
    self.game_layer.do(CommonLayers.PlayLayerAction())
示例#13
0
 def on_host_game(self):
     """ """
     self.serverLayer = self.makeServerLayer()
     scene = cocos.scene.Scene(self.serverLayer)
     cocos.director.director.replace(FadeTRTransition(scene, 2))
     self.serverLayer.start(self, self.host, self.port)
示例#14
0
 def on_new_game(self):
     director.push(FadeTRTransition(new_game(self.level_start), duration=2))
示例#15
0
 def on_join_game(self):
     """ """
     playLayer = ClientPlayLayer.ClientPlayLayer(self.host, self.port,
                                                 self.player_name)
     cocos.director.director.replace(
         FadeTRTransition(cocos.scene.Scene(playLayer), 2))
示例#16
0
 def on_host_game(self):
     """ """
     cocos.director.director.replace(
         FadeTRTransition(
             cocos.scene.Scene(ServerPlayLayer.ServerPlayLayer(self.port)),
             2))
示例#17
0
 def on_new_game(self):
     #director.scaled_resize_window(1280, 960)
     director.push(FadeTRTransition(new_game(), duration=2))
 def on_new_game(self):
     director.push(FadeTRTransition(new_game(), duration=2))
示例#19
0
 def on_new_game(self):  #轉場功能,點擊New Game在2秒內轉場至遊戲場景 FadeTRTransition是轉場特效
     director.push(FadeTRTransition(new_game(), duration=2))