def is_mouse_in_rect(self, event, reset_focus=True): flag = self.game_object.screen_rect.collidepoint( event.pos[0], event.pos[1]) # 且鼠标在ui的范围内 if flag: director.mouse.press() if reset_focus: post_event({ "name": "reset_ui_focus", "set_focus_obj": self.game_object }) return flag
def _find_path(self, event, is_running): left_top = self.state.game_object.get_left_top() # screen左上角世界坐标 source = director.account.get_main_role().get_xy() # main_role当前坐标 target = (event.pos[0] + left_top[0], event.pos[1] + left_top[1] ) # screen左上角世界坐标 + screen鼠标位置 = 鼠标世界坐标 path_list = self.state.game_object.map_x.find_path(source, target) post_event({ 'name': "receive_path_list", 'path_list': path_list, 'is_running': is_running })
def on_mouse_left_up(self, event): if self.is_mouse_in_rect(event): event.handled = True self.game_object.focus = True # 如果鼠标仍在范围之内 role_name = self.game_object.parent.role_name_input.input_string if role_name == "": # 如果角色名为空 post_event({"name": "notify", "text": "请输入角色名"}) else: network_client.request( send_data={ "action": "create_role", "role_name": role_name, "character_race": self.game_object.parent.store["character_race"], "character_version": self.game_object.parent.store["character_version"], "character_name": self.game_object.parent.store["character_name"] }) self.game_object.is_mouse_up = True
def on_receive_account(self, event): from core.event.event import post_event from game.scene.role_select.role_select_scene import RoleSelectScene self.director.account = Account(event.account) post_event({"name": "change_scene", "scene": RoleSelectScene}) event.handled = True
def network(data): data["name"] = data["action"] post_event(data)
def network_request(self): self.director.network_client.request( send_data={"action": "get_announcement"}) from core.event.event import post_event post_event({"name": "notify", "text": "大话西游#24大游大话西游大话大话西游大话西游大话西游"}) post_event({"name": "notify", "text": "大话西游"})
def on_receive_new_role(self, event): from core.event.event import post_event from game.scene.role_select.role_select_scene import RoleSelectScene post_event({"name": "change_scene", "scene": RoleSelectScene}) event.handled = True