def timer(interval): director.scene_stack.clear() global place # Get turn info from logs, if None go to end scene # on the end scene the end_boolean is checked, and if False, the visualizer will close after 4 seconds turn_info = log_parser.get_turn(global_stats.turn_num) if turn_info is None: end_layer = EndLayer(size, log_parser) end_scene = cocos.scene.Scene().add(end_layer) director.replace(end_scene) if not end_boolean: end_scene.schedule_interval(exit, 10) else: # If a disaster happens, slow down the interval rate intval = global_stats.base_turn_time * global_stats.turn_speed for key, item in (turn_info['rates'].items()): if item == 0: intval = global_stats.disaster_turn_time * global_stats.turn_speed clock = TimeLayer(size, turn_info, global_stats.turn_num, place) clock.schedule_interval(callback=timer, interval=intval) current_scene = create_scene(turn_info, log_parser) current_scene.add(clock, 100) director.replace(current_scene) global_stats.turn_num += 1
def __init__(self, args): self.args = args pyglet.resource.path.append(os.path.join(dname,'resources')) pyglet.resource.reindex() pyglet.font.add_file('resources/DejaVuSans.ttf') pyglet.font.add_file('resources/unifont.ttf') director.set_show_FPS(False) w = director.init(fullscreen=True, caption=self.title, visible=True, resizable=True) # width = director.window.width # height = director.window.height # wnew, hnew = int(width * .75), int(height * .75) # director.window.set_fullscreen(False) # director.window.set_size(wnew, hnew) # w.set_location((width-wnew)/2, (height-hnew)/2) director.window.pop_handlers() director.window.push_handlers(Handler()) self.gameScene = Scene() self.gameLayer = AgarLayer() self.gameScene.add(self.gameLayer) director.replace(self.gameScene) director.window.set_visible(True)
def remove(self, obj): if obj is self.bunker: director.replace(SplitColsTransition(game_over())) elif isinstance(obj, actors.Enemy) and obj.destroyed: self.score += obj.score self.points += 5 super(GameLayer, self).remove(obj)
def on_key_press(self, key, modifiers): """key press handler for menu class """ self.keys_pressed.add(key) key_names = [ pyglet.window.key.symbol_string(k) for k in self.keys_pressed ] if 'ENTER' in key_names: #Start the game self.keys_pressed.clear() self.game.show_game() director.replace(Scene(game_screen)) # use the LEFT or RIGHT to change the game level elif 'LEFT' in key_names: if self.game.level != 'Normal': self.game.level = 'Normal' materials.menu.labels[ 'level_label'].element.text = self.game.level elif 'RIGHT' in key_names: if self.game.level != 'Hard': self.game.level = 'Hard' materials.menu.labels[ 'level_label'].element.text = self.game.level elif 'F12' in key_names: file_test.init_file() materials.menu.show_highscore()
def step(self,dt): global newton, apple, lives_c, begin, end, vel_y_5 super().step(dt) vel_x = 0 vel_y_5 = vel_y_5 - 5.6 self.target.velocity = (vel_x,vel_y_5) if (self.target.position[1] < -36 ): pos_x = random.randint(30, 930) pos_y = 800 vel_y_5 = 0 self.target.position = (pos_x, pos_y) if (self.target.position[1] < 300 and (abs(self.target.position[0] - newton.position[0])<100)): pos_x = random.randint(30, 930) pos_y = 800 self.target.position = (pos_x, pos_y) vel_y_5 = 0 lives_c=lives_c-1 if (lives_c==0): end=time.time() print(end-begin) pos_x = random.randint(30, 930) pos_y = 800 vel_y_5 = 0 director.replace(menu_scene)
def cb(self): if self.k == key.ENTER: self.scene_index += 1 self.scene_index %= len(self.scenes) scene = self.scenes[self.scene_index] transition = eval(self.item) director.replace(transition(scene, 1))
def show_info(self): """display the screen of player information (where you check the skills, item equipped and the item-box) """ my_info.status = 'view' director.replace(Scene(my_info)) self.refresh_info()
def bump(self): w,h = director.get_window_size() collman = cm.CollisionManagerGrid(0.0, w, 0.0, h, 10,10) self.hero.cshape = cm.CircleShape(eu.Vector2(self.hero.x, self.hero.y), 50) collman.add(self.hero) for one in self.bullets.get_children(): one.cshape=cm.AARectShape(eu.Vector2(one.x, one.y), 5,10 ) collman.add(one) for oneEnemy in self.enemies.get_children(): oneEnemy.cshape=cm.AARectShape(eu.Vector2(oneEnemy.x, oneEnemy.y), 25*oneEnemy.type,25*oneEnemy.type ) collman.add(oneEnemy) for oneEnemy in self.enemies.get_children(): for oneBullet in self.bullets.get_children(): if collman.they_collide(oneEnemy, oneBullet): self.enemies.remove(oneEnemy) self.bullets.remove(oneBullet) self.score+=50 break for oneEnemy in self.enemies.get_children(): if collman.they_collide(oneEnemy,self.hero): self.enemies.remove(oneEnemy) #self.remove(hero) #print "you lose!!!!!!!" GameOverLayer=GameOver () gameover=cocos.scene.Scene (GameOverLayer) director.replace (gameover)
def on_key_press(self, symbol, modifiers): "Change scene when user hit ENTER key." if symbol == pyglet.window.key.RETURN: new_scene = Scene(Main()) transition = custom_transition.ZoomTransition(director.scene, new_scene) director.replace(transition)
def back(self): bg_1 = BG(bg_name="img/start_bg.png") # 1.获取背景图片路径 scene_1 = cocos.scene.Scene(bg_1) # 2.把背景图片生成scene scene_1_menu = Main_menu() scene_1.add(scene_1_menu) # 4.把按钮加入到scene director.replace( scenes.transitions.SlideInBTransition(scene_1, duration=1))
def remove(self, obj): if obj is self.bunker: #如果被刪除的是碉堡 代表失敗,轉場至失敗場景 director.replace(SplitColsTransition(game_over())) elif isinstance(obj, actors.Enemy) and obj.destroyed: #如果是敵人且是因為射擊而被破壞而不是撞到碉堡(碉堡不用給分數),則給玩家分數、點數 self.score += obj.score self.points += 5 super(GameLayer, self).remove(obj) #最後才用super使用原本內建的remove方法(先使用會導致先刪除)
def _enter_page(self, page, forward=True): # set up the initial page old_page = self.page self.page = page bgcolor = page.content.stylesheet['layout']['background_color'] bgcolor = [c/255. for c in bgcolor] pyglet.gl.glClearColor(*bgcolor) page.desired_size = self.desired_size # play the transition, if any if forward and page.transition is not None: duration = page.stylesheet['transition']['duration'] page.transition(page) elif not forward and old_page.transition is not None: duration = old_page.stylesheet['transition']['duration'] old_page.transition(page) else: duration = 0 director.replace(page) # and cue up the on_page_changed event for when the transition finishes # XXX would be nice to be able to be notified by Cocos when the transition finishes def f(dt, self=self): self.dispatch_event('on_page_changed', self.page, self.page_num) pyglet.clock.schedule_once(f, duration + 0.1) director.window.set_caption('Presentation: Slide %s'%(self.page_num+1))
def on_restart(self): clicksound.play() #go back to main scene time.sleep(0.5) director.replace(FadeTransition(main_scene, duration=1)) audiomixer.pause() self.game.reset()
def _enter_page(self, page, forward=True): # set up the initial page old_page = self.page self.page = page bgcolor = page.content.stylesheet['layout']['background_color'] bgcolor = [c / 255. for c in bgcolor] pyglet.gl.glClearColor(*bgcolor) page.desired_size = self.desired_size # play the transition, if any if forward and page.transition is not None: duration = page.stylesheet['transition']['duration'] page.transition(page) elif not forward and old_page.transition is not None: duration = old_page.stylesheet['transition']['duration'] old_page.transition(page) else: duration = 0 director.replace(page) # and cue up the on_page_changed event for when the transition finishes # XXX would be nice to be able to be notified by Cocos when the transition finishes def f(dt, self=self): self.dispatch_event('on_page_changed', self.page, self.page_num) pyglet.clock.schedule_once(f, duration + 0.1) director.window.set_caption('Presentation: Slide %s' % (self.page_num + 1))
def on_mouse_press(self, x, y, buttons, modifiers): global volume_avg_list, pitch_avg_list, volume_talk_avg, pitch_talk_avg, volume_sing_avg, pitch_sing_avg self.position_x, self.position_y = director.get_virtual_coordinates( x, y) print(self.position_x) print(self.position_y) if ((840 < self.position_x < 860) and (270 < self.position_y < 290)): self.remove(self.talk_1) self.remove(self.talk_2) self.remove(self.button) self.button.position = (850, 90) self.add(self.button) self.add(self.sing_1) self.add(self.sing_2) volume_talk_avg = sum(volume_avg_list) / len(volume_avg_list) print("Average talk volume is %s" % (volume_talk_avg)) pitch_talk_avg = sum(pitch_avg_list) / len(pitch_avg_list) print("Average talk pitch is %s" % (pitch_talk_avg)) volume_avg_list = [] pitch_avg_list = [] if ((840 < self.position_x < 860) and (70 < self.position_y < 90)): #clicksound.play(self.talk) main_scene = cocos.scene.Scene() main_scene.add(scroller) main_scene.add(InputVoice()) volume_sing_avg = sum(volume_avg_list) / len(volume_avg_list) print("Average volume is %s" % (volume_sing_avg)) pitch_sing_avg = sum(volume_avg_list) / len(volume_avg_list) print("Average pitch is %s" % (pitch_sing_avg)) director.replace(FadeTransition(main_scene, duration=1))
def on_key_press(self, k, m): if k in (key.ENTER, key.ESCAPE, key.SPACE, key.Q): if self.in_highscore: director.replace(Scene(SubmitScore(self.wave))) else: director.pop() return True
def load_track(self, dt, *args, **kwargs): if not self.images_loaded: self.track.load_images() self.label.text = self.text + '5%' self.total = len(self.track.partition_list) self.images_loaded = True elif not self.overlay_loaded: self.track.load_overlay() self.label.text = self.text + '25%' self.overlay_loaded = True else: partitions_left = self.track.load_partitions() percent = 25 + int( ((self.total - partitions_left) * 1.0 / self.total) * 75) self.label.text = self.text + str(percent) + '%' if partitions_left == 0: # load the music last self.track.load_music() # hack to prevent circular imports from race import Race race = Race(self.track, [ state.profile.car, ComputerCar.get_default(), ComputerCar.get_default() ]) director.replace(race)
def on_key_press(self, key, modifiers): k = symbol_string(key) status = True if k == "LEFT": self.key_pressed_left = status elif k == "RIGHT": self.key_pressed_right = status elif k == "SPACE" and self.life == 1: if self.jump_count > 0: x, y = self.sprite.position try: self.remove(self.jump1) except: pass # jump效果图 self.jump1 = Sprite("images/jump.png") self.jump1.opacity = 250 self.jump1.position = (x, y-100) self.add(self.jump1) self.jump_speed = 20 self.jump_y = y self.key_pressed_up = True self.jump_count -= 1 elif k == "DOWN": self.key_pressed_down = status elif k == "SPACE" and self.life == 0: scene = Scene(GameLayer()) director.replace(SplitColsTransition(scene))
def update_newlevel(self): if len(self.blocks) == 0: self.level.next() print(self.level.levels) # self.reset() scene = Scene(GuoCangDongHua(self.level.levels, self.gold, self.deadcount)) director.replace(scene)
def on_key_press(self, key, modifiers): print(key) print(pyglet.window.key.symbol_string(key)) if self.webOpen: if ord('a') <= key <= ord('z'): if len(self.name) < 6: self.name += pyglet.window.key.symbol_string(key) #self.nameLabel.element.text = self.name if pyglet.window.key.symbol_string(key) == 'BACKSPACE': if len(self.name) != 0: self.name = self.name[:-1] #self.nameLabel.element.text = self.name if pyglet.window.key.symbol_string(key) == 'RETURN': if (self.name == ''): self.name = 'NONAME' scoreManageFrame.updateScore(self.score, self.name) del self scene = cocos.scene.Scene() titleFrame = TitleFrame() if (have_avbin): music_player.queue( pyglet.resource.media('MainMenu.mp3', streaming=True)) music_player.queue( pyglet.resource.media('OST.mp3', streaming=True)) music_player.next() scene.add(titleFrame) director.replace(scene)
def increment_sprites(self, packet): # changes the position of the sprites global transition global spaghetti_names global IDENTIFIER global timeLeft global p1_score, p2_score #print("ID", IDENTIFIER) self.packet_dict = json.loads( packet) # receieve the json from the server timeLeft = self.packet_dict[ 'time'] #unpack it and edit the global gamestate p1_score = self.packet_dict['p1_score'] p2_score = self.packet_dict['p2_score'] if int(timeLeft) == 0 and not transition: # if the game is over #print ("Negative") transition = True timeLeft = -1 #self.updateLoop.stop() director.replace(FadeTransition(Scene( endLayer()))) # transition to the game over screen #reactor.stop() if int(timeLeft) < 0: # stop looping if the time is negative return #self.updateLoop.end() #print(self.packet_dict) for el in self.packet_dict: # use the information from the server to update the position of the spagetti if el != IDENTIFIER and el in ["client0", "client1"]: #print(el) self.sprite_vector[el].position = tuple( self.packet_dict[el]['position']) if el in spaghetti_names: self.spaghetti[el].position = tuple( self.packet_dict[el]['position'])
def on_mouse_press(self, x, y, buttons, modifiers): global volume_avg_list, pitch_avg_list, volume_talk_avg, pitch_talk_avg, volume_sing_avg, pitch_sing_avg, volume_std self.position_x, self.position_y = director.get_virtual_coordinates( x, y) print(self.position_x) print(self.position_y) if ((840 < self.position_x < 860) and (270 < self.position_y < 290)): self.remove(self.talk_1) self.remove(self.talk_2) self.remove(self.button) self.button.position = (850, 90) self.add(self.button) self.add(self.sing_1) self.add(self.sing_2) self.add(self.sing_3) volume_talk_avg = np.array(volume_avg_list).mean() print("Average talk volume is %s" % (volume_talk_avg)) pitch_talk_avg = np.array(pitch_avg_list).mean() print("Average talk pitch is %s" % (pitch_talk_avg)) volume_avg_list = [] pitch_avg_list = [] if ((840 < self.position_x < 860) and (70 < self.position_y < 90)): clicksound.play() main_scene = cocos.scene.Scene() main_scene.add(scroller) main_scene.add(InputVoice()) volume_sing_avg = np.array(volume_avg_list).mean() volume_std = np.array(volume_avg_list).std() print("Average volume is %s" % (volume_sing_avg)) pitch_sing_avg = np.array(pitch_avg_list).mean() print("Average pitch is %s" % (pitch_sing_avg)) # menuLayer_back = MultiplexLayer(MainMenus()) # main_menu_scene = cocos.scene.Scene(scroller_menu,menuLayer_back) director.replace(FadeTransition(main_scene, duration=1))
def run(self, *args): if not self.has_ran: self.has_ran = True move_to(self.game, 0, 5) with suppress(Exception): director.replace( FadeTRTransition(self.meta['scenes']['runner']))
def enemy_dies(self, enemy): self.get("splat").do(FadeIn(0.2) + FadeOut(3)) self.remove(enemy) self.enemies.remove(enemy) self.lives -= 1 if self.lives <= 0: director.replace(TurnOffTilesTransition(GameOver(), 2.0))
def ChangeScene(index): gVariables.g_scene = index if index == 0: director.replace(FadeTransition(Scene(MenuScene(gVariables.g_RESOURCES)))) elif index == 1: director.replace(FadeTransition(Scene(GameScene(gVariables.g_RESOURCES)))) else: exit(0)
def remove(self, obj): """Override remove() to detect which type of object has been removed""" if obj is self.bunker: director.replace(SplitColsTransition(game_over())) elif isinstance(obj, actors.Enemy) and obj.destroyed_by_turret: self.score += obj.score self.points += 5 super(GameLayer, self).remove(obj)
def on_key_press(self, key_code, modifiers): """ invoked when the user presses a keyboard key """ if key_code == key.ENTER: director.replace(NotifiyingTransition(GAME_SCENE, GAME_MODEL.start)) # SOUND_MANAGER.buzz_sound.play() return True else: return False
def on_next(self): global progress if progress < self.progress: progress = self.progress if self.next_scene == 'themes_menu': global background self.next_scene = cocos.scene.Scene(background, ThemesMenu()) director.replace(self.next_scene)
def on_actor_enter(self, actor): # Only the player can use portals if actor == self.parent.player: map = loadmap.load(self.map_file, None) map['actors'].add_object(actor) map.player = actor actor.position = map.find_actor(self.exit_id).position director.replace(map)
def finish(self): '''Called when the time is over. It removes both the incoming and the outgoing scenes from the transition scene, and restores the outgoing scene's attributes like: position, visible and scale. ''' self.remove( self.in_scene ) self.restore_out() director.replace( self.in_scene )
def finish(self): '''Called when the time is over. It removes both the incoming and the outgoing scenes from the transition scene, and restores the outgoing scene's attributes like: position, visible and scale. ''' self.remove(self.in_scene) self.restore_out() director.replace(self.in_scene)
def show_combat(self, worldmap=None): """ switches to world map scene :param worldmap: str, absolute path to world map file """ if "combat" not in self.scenes: self.scenes["combat"] = SceneCombat() director.core.switch_intro_music(False) director.replace(self.scenes["combat"])
def transition(self, transition=None): if transition: director.replace( transition( self.scenes[ self.scene_p ], duration = 1 ) ) else: director.replace( self.scenes[ self.scene_p ] )
def on_enemy_reached_goal(self): """ Gets called everytime an enemy reached the final cell. Transistion to the GameOver Screen when the game is finished. """ self.currentLives -= 1 self.hud.update_live_number(self.currentLives) if self.currentLives == 0: director.replace(PyFenseLost())
def on_key_press( self, k , m ): global game_scene if k == key.SPACE: self.fn_start_game() director.replace(ZoomTransition(game_scene,1.25)) if k == key.ESCAPE: exit() return True
def update_timer(self, *args, **kwargs): """Update timer.""" if self.timer >= len(self.game.state): move_to(self.game, self.timer - 1, len(self.game.state) + 5) director.replace(FadeTRTransition(self.meta['scenes']['runner'])) self.timer += 1 self.label.element.text = "%s -> %s" % (self.meta["current_world"], str(self.timer))
def on_key_press(self, key, mi): k = symbol_string(key) if (k == 'R') or (k == 'C'): if k == 'R': scene = Scene(GameLayer()) elif k == 'C': print(1) scene = Scene(GameLayer(self.levels, self.gold, self.deadcount)) director.replace(scene)
def start_iti(self, *a): '''Starts inter-trial interval following feedback''' schedule_once(self.start_trial, self.duration_iti) if self.session_ended: func = self.end_session else: func = self.start_trial schedule_once(func, self.duration_iti) director.replace(Scene(lr.back))
def end_session(self, status='', set_time=True): if set_time: self.set_time() self.unschedule_all() self.session_ended = True if status == 'concluded': lr.end.concluded() self.record_end(status) director.replace(Scene(lr.back, lr.end))
def on_key_press(self, key, m): k = symbol_string(key) print(k) if k == 'S': self.save_file('levelfile/level1.txt', self.pos) self.saveflag.element.text = '已保存' elif k == 'P': scenes = Scene(main.Start()) director.replace(SplitColsTransition(scenes))
def on_key_press(self, key_code, modifiers): """ invoked when a keyboard key is pressed see CocosNode """ if key_code == key.ESCAPE: director.replace(RotoZoomTransition((HOME_SCENE), 1.25)) # SOUND_MANAGER.buzz_sound.play() return True else: return False
def on_key_press(self, key, modifiers): k = symbol_string(key) if k == "UP": self.j -= 1 if self.j < 0: self.j = 0 if self.j == 2: self.label1.element.text = "纸醉金迷" elif self.j == 1: self.label1.element.text = "交易赌局" elif self.j == 0: self.label1.element.text = "金钱崇拜" elif k == "DOWN": self.j += 1 if self.j > 2: self.j = 2 if self.j == 2: self.label1.element.text = "纸醉金迷" elif self.j == 1: self.label1.element.text = "交易赌局" elif self.j == 0: self.label1.element.text = "金钱崇拜" elif k == "LEFT": self.i -= 1 if self.i < 0: self.i = 0 if self.i == 2: self.label.element.text = "爷爷" elif self.i == 1: self.label.element.text = "爸爸" elif self.i == 0: self.label.element.text = "老公" self.remove(self.sprite) self.sprite = Sprite(role_choose[self.i]) self.sprite.position = (500, 450) self.add(self.sprite) elif k == "RIGHT": self.i += 1 if self.i > 2: self.i = 2 if self.i == 2: self.label.element.text = "爷爷" elif self.i == 1: self.label.element.text = "爸爸" elif self.i == 0: self.label.element.text = "老公" self.remove(self.sprite) self.sprite = Sprite(role_choose[self.i]) self.sprite.position = (500, 450) self.add(self.sprite) elif k == "SPACE": global choose_i, choose_j choose_i = self.i choose_j = self.j print(choose_i) scene = Scene(GameLayer()) director.replace(SplitColsTransition(scene))
def playClicked(self): #save the inventory to ensure the buy's are not lost Inventory.save() game = gameplay.GamePlay() # A scene that contains the layer hello_layer main_scene = cocos.scene.Scene (game) # And now, start the application, starting with main_scene director.replace(main_scene)
def char_die(self): global lives if(lives>0): lives -= 1 self.osd.update() director.replace(FadeTransition(game_scene.cur_level(),duration=1)) else: director.replace(FadeTransition(game_scene.GameOverScene(),duration=1)) lives = char_initial_lives
def update(self, dt): global game_scene, socket_mgr, use_kinect if use_kinect and socket_mgr: socket_mgr.send('get\n') response = socket_mgr.receive() if 'Wave' in response: self.fn_start_game() director.replace(ZoomTransition(game_scene,1.25))
def playClicked(self): #save the inventory to ensure the buy's are not lost Inventory.save() game = gameplay.GamePlay() # A scene that contains the layer hello_layer main_scene = cocos.scene.Scene(game) # And now, start the application, starting with main_scene director.replace(main_scene)
def on_key_press(self, key, m): k = symbol_string(key) if k == 'S': # 按S键保存 self.save_file('levelfile/level'+str(self.save_as)+'.txt', self.blocks) self.reset_level_select() self.saveflag.element.text = '已保存' elif k == 'P': # 按P键开始游戏 scenes = Scene(main.Background(), main.Start()) director.replace(SplitColsTransition(scenes))
def status_detect(self, dt): self.bullet.cshape.center = self.bullet.position if self.bullet_move: if self.count <= 4: self.count += 1 x, y = self.bullet.position self.bullet.position = x + 40, y else: self.refresh() elif self.status == 1: if (keyboard[key.J]): self.status = 4 global block_1 block_1 = True self.skin.do(skeleton.Animate(self.attack)) timer = threading.Timer(0.3, self.recover) timer.start() bullet_sound = pygame.mixer.Sound(address_2 + '/sound/bullet.wav') bullet_sound.set_volume(0.5) bullet_sound.play() x, y = self.skin.position self.bullet.position = x + 110, y + 70 self.bullet_move = True elif (keyboard[key.L]): self.status = 5 block_1 = True self.skin.do(skeleton.Animate(self.leg_attack)) timer = threading.Timer(0.35, self.recover) timer.start() elif (keyboard[key.K] and not self.down): self.status = 6 self.skin.do(skeleton.Animate(self.jump)) self.up = True timer_2 = threading.Timer(0.5, self.down_change) timer_2.start() elif ((keyboard[key.D] and not block_1_R) or (keyboard[key.A])): # key right and not attack 得改成状态保持 self.status = 2 self.skin.do(cocos.actions.Repeat(skeleton.Animate(self.walk))) if (self.status == 2 and not (keyboard[key.D] or keyboard[key.A])): self.recover() if self.beheat and self.status != 3: self.remove_all() self.status = 3 self.beheat = False block_1 = True self.skin.do(skeleton.Animate(self.frozen)) timer = threading.Timer(0.5, self.recover) timer.start() if self.life <= 0: del self #这里确定没有问题?? scene_2 = cocos.scene.Scene(VF_Layer(True), Game_menu(), Drag(), MouseDisplay()) director.replace( scenes.transitions.SlideInBTransition(scene_2, duration=1))
def remove(self, obj): # if bunker destroyed, player lost and game over scene # is transitioned into if obj is self.bunker: director.replace(SplitColsTransition(game_over())) elif isinstance(obj, actors.Enemy) and obj.destroyed_by_player: self.score += obj.points self.points += 5 super(GameLayer, self).remove(obj)
def on_key_press(self, key, mi): k = symbol_string(key) print(k) if k =='S': scenes = Scene(GuoCangDongHua()) director.replace(SplitColsTransition(scenes)) elif k == 'E': scenes = Scene(editor.Editor()) director.replace(SplitColsTransition(scenes))
def show_title_screen(self): """return to title""" if "title" not in self.scenes: title_screen = DisplayTitle() self.scenes["title"] = Scene(title_screen) director.run(self.scenes["title"]) else: director.replace( RotoZoomTransition(self.scenes["title"], duration=2))
def on_quit(self): print("Back to the previous menu...") director.pop() if self.unit_changed: # unit changed, so the player units menu needs to be reloaded scene = cocos.scene.Scene() scene.add(PlayerUnitsMenu(player=self.player, tech=self.tech)) director.replace(FlipX3DTransition(scene, duration=0.5))
def on_key_press(self, key, mi): if self.is_on_exiting: k = symbol_string(key) if (k == 'R') or (k == 'C'): self.is_on_exiting = False if k == 'R': scene = create_scene(Start()) elif k == 'C': scene = create_scene(GameLayer(self.hud)) director.replace(SplitColsTransition(scene))
def on_key_press(self, k, m): if k == key.ESCAPE: director.push(pause.PyFensePause()) return True if k == key.Q: director.replace(highscore.PyFenseLost()) if k == key.B: import pdb pdb.set_trace() return True
def step(self,dt): if(self.playing): delta = self.speed*dt self.fx += delta self.parent.wobble.x -= delta self.manager.set_focus(self.fx, self.fy) if(self.parent.px_width - self.fx <= 400): director.replace(FadeTransition(game_scene.next_level(),duration=1)) self.playing = False
def update_newlevel(self): if len(self.level.blocks) == 0: self.is_on_exiting = False if self.level.next(): print(self.level.levels) self.hud.levels += 1 scene = create_scene(GuoCangDongHua(self.hud)) else: scene = create_scene(GameComplite(self.hud)) director.replace(scene)