diff --git a/resources/graphics/Screen/returnButton.png b/resources/graphics/Screen/returnButton.png deleted file mode 100644 index 28bcfe9..0000000 Binary files a/resources/graphics/Screen/returnButton.png and /dev/null differ diff --git a/source/component/menubar.py b/source/component/menubar.py index d11ef42..6eb4330 100755 --- a/source/component/menubar.py +++ b/source/component/menubar.py @@ -13,7 +13,7 @@ def getSunValueImage(sun_value): msg_rect = msg_image.get_rect() msg_w = msg_rect.width - image = pg.Surface([width, 17]) + image = pg.Surface((width, 17)) x = width - msg_w image.fill(c.LIGHTYELLOW) diff --git a/source/constants.py b/source/constants.py index e5ed656..3204b57 100755 --- a/source/constants.py +++ b/source/constants.py @@ -79,7 +79,6 @@ EXIT = 'exit' # 游戏界面可选的菜单 LITTLE_MENU = 'littleMenu' BIG_MENU = 'bigMenu' -RETURN_BUTTON = 'returnButton' RESTART_BUTTON = 'restartButton' MAINMENU_BUTTON = 'mainMenuButton' LITTLEGAME_BUTTON = 'littleGameButton' diff --git a/source/state/level.py b/source/state/level.py index 2ce90dc..4fd2c9b 100644 --- a/source/state/level.py +++ b/source/state/level.py @@ -510,12 +510,20 @@ class Level(tool.State): self.big_menu_rect.x = 150 self.big_menu_rect.y = 0 - # 返回按钮 - frame_rect = (0, 0, 342, 87) - self.return_button = tool.get_image_menu(tool.GFX[c.RETURN_BUTTON], *frame_rect, c.BLACK, 1.1) + # 返回按钮,用字体渲染实现,增强灵活性 + # 建立一个按钮大小的surface对象 + self.return_button = pg.Surface((376, 96)) + self.return_button.set_colorkey(c.BLACK) # 避免多余区域显示成黑色 self.return_button_rect = self.return_button.get_rect() self.return_button_rect.x = 220 self.return_button_rect.y = 440 + font = pg.font.Font(c.FONT_PATH, 40) + font.bold = True + text = font.render("返回游戏", True, c.YELLOWGREEN) + text_rect = text.get_rect() + text_rect.x = 105 + text_rect.y = 18 + self.return_button.blit(text, text_rect) # 重新开始按钮 frame_rect = (0, 0, 207, 45) diff --git a/source/state/mainmenu.py b/source/state/mainmenu.py index d4db631..8a24ed9 100644 --- a/source/state/mainmenu.py +++ b/source/state/mainmenu.py @@ -167,12 +167,20 @@ class Menu(tool.State): self.big_menu_rect.x = 150 self.big_menu_rect.y = 0 - # 返回按钮 - frame_rect = (0, 0, 342, 87) - self.return_button = tool.get_image_menu(tool.GFX[c.RETURN_BUTTON], *frame_rect, c.BLACK, 1.1) + # 返回按钮,用字体渲染实现,增强灵活性 + # 建立一个按钮大小的surface对象 + self.return_button = pg.Surface((376, 96)) + self.return_button.set_colorkey(c.BLACK) # 避免多余区域显示成黑色 self.return_button_rect = self.return_button.get_rect() self.return_button_rect.x = 220 self.return_button_rect.y = 440 + font = pg.font.Font(c.FONT_PATH, 40) + font.bold = True + text = font.render("返回游戏", True, c.YELLOWGREEN) + text_rect = text.get_rect() + text_rect.x = 105 + text_rect.y = 18 + self.return_button.blit(text, text_rect) # 音量+、音量- frame_rect = (0, 0, 39, 41)