Skip to content

Commit

Permalink
Merge pull request #63 from ligen131/fix-20240219-small-bugs
Browse files Browse the repository at this point in the history
fix: 修复了导致运行失败的 bug
  • Loading branch information
cutekibry authored Feb 19, 2024
2 parents 66e352b + 18dddba commit 1e64679
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions levels/chapter_menu/level_menu/level_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ const button_heigth : int = 50

func init(chap_id: int) -> void:
self.chapter_id = chap_id
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"]
$LevelMenuCamera.init_position(Vector2(WIDTH * chap_id, 0))

$UI/PreviousChapterButton.set_disabled(chapter_id == 0)
$UI/NextChapterButton.set_disabled(chapter_id == LevelData.get_chapter_count() - 1)

func _ready():
for cid in range(LevelData.get_chapter_count()):
for lid in range(LevelData.get_chapter_level_count(cid)):
Expand All @@ -28,9 +31,6 @@ func _ready():
button.init(cid, lid, Vector2(x, y), 1)
button.enter_level.connect(_on_button_enter_level)
$LevelButtons.add_child(button)

$UI/PreviousChapterButton.set_disabled(chapter_id == 0)
$UI/NextChapterButton.set_disabled(chapter_id == LevelData.get_chapter_count() - 1)


func _on_button_enter_level(chap_id: int, lvl_id: int) -> void:
Expand All @@ -43,17 +43,17 @@ func _on_button_enter_level(chap_id: int, lvl_id: int) -> void:

func _on_previous_chapter_button_pressed():
self.chapter_id -= 1
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"]
$UI/PreviousChapterButton.set_disabled(true)
$UI/NextChapterButton.set_disabled(true)


func _on_next_chapter_button_pressed():
self.chapter_id += 1
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]
$UI/Title.text = LevelData.CHAP_NAMES[chapter_id]["name-en"]
$UI/PreviousChapterButton.set_disabled(true)
$UI/NextChapterButton.set_disabled(true)

func _on_smooth_movement_timeout():
$UI/PreviousChapterButton.set_disabled(chapter_id == 0)
$UI/NextChapterButton.set_disabled(chapter_id == LevelData.get_chapter_count() - 1)
$UI/NextChapterButton.set_disabled(chapter_id == LevelData.get_chapter_count() - 1)
2 changes: 1 addition & 1 deletion levels/chapter_menu/level_menu/level_menu_camera.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Camera2D
class_name LevelMenuCamera extends Camera2D


const WIDTH := 1920 / 4
Expand Down
1 change: 0 additions & 1 deletion objects/main_menu/main_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ extends Node2D

class_name MainMenu

const ChapterMenuScn := preload("res://levels/chapter_menu/chapter_menu.tscn")
const BaseLevelScn := preload("res://levels/base_level/base_level.tscn")

signal enter_level()
Expand Down

0 comments on commit 1e64679

Please sign in to comment.