书架 hover 高亮;成功后高亮+锁定
This commit is contained in:
parent
461bc21344
commit
73b640fdb4
@ -65,7 +65,11 @@ func _init_answer_and_connect_signals() -> void:
|
|||||||
arr.append(id)
|
arr.append(id)
|
||||||
var book = _get_book_by_id(row, id)
|
var book = _get_book_by_id(row, id)
|
||||||
if not Engine.is_editor_hint():
|
if not Engine.is_editor_hint():
|
||||||
book.get_node("BookButton").pressed.connect(_on_book_pressed.bind(row, id))
|
var btn = book.get_node("BookButton") as TextureButton
|
||||||
|
btn.pressed.connect(_on_book_pressed.bind(row, id))
|
||||||
|
btn.mouse_entered.connect(_on_book_hover.bind(true, row, btn))
|
||||||
|
btn.mouse_exited.connect(_on_book_hover.bind(false, row, btn))
|
||||||
|
btn.self_modulate = Color.GRAY
|
||||||
current_answer.append(arr)
|
current_answer.append(arr)
|
||||||
|
|
||||||
|
|
||||||
@ -131,6 +135,15 @@ func _on_book_pressed(row: int, id: int) -> void:
|
|||||||
selected_book = [row, col]
|
selected_book = [row, col]
|
||||||
|
|
||||||
|
|
||||||
|
func _on_book_hover(hover: bool, row: int, btn: TextureButton) -> void:
|
||||||
|
if gameover or row_correct_status[row]:
|
||||||
|
return
|
||||||
|
if hover:
|
||||||
|
btn.self_modulate = Color.WHITE
|
||||||
|
else:
|
||||||
|
btn.self_modulate = Color.GRAY
|
||||||
|
|
||||||
|
|
||||||
func _get_book_by_id(row: int, id: int) -> Node2D:
|
func _get_book_by_id(row: int, id: int) -> Node2D:
|
||||||
return get_node("./Shelf/Layer" + str(row) + "/Book" + str(id))
|
return get_node("./Shelf/Layer" + str(row) + "/Book" + str(id))
|
||||||
|
|
||||||
@ -199,6 +212,11 @@ func _check_answer() -> void:
|
|||||||
if row_success:
|
if row_success:
|
||||||
row_correct_status[0] = true
|
row_correct_status[0] = true
|
||||||
$SfxRowSuccess.play()
|
$SfxRowSuccess.play()
|
||||||
|
# set modulate back to white
|
||||||
|
for col in range(row1.size()):
|
||||||
|
var book = _get_book_by_id(0, col)
|
||||||
|
var btn = book.get_node("BookButton") as TextureButton
|
||||||
|
btn.self_modulate = Color.WHITE
|
||||||
|
|
||||||
# 第二行需要正序排列
|
# 第二行需要正序排列
|
||||||
if not row_correct_status[1]:
|
if not row_correct_status[1]:
|
||||||
@ -212,6 +230,12 @@ func _check_answer() -> void:
|
|||||||
if row_success:
|
if row_success:
|
||||||
row_correct_status[1] = true
|
row_correct_status[1] = true
|
||||||
$SfxRowSuccess.play()
|
$SfxRowSuccess.play()
|
||||||
|
# set modulate back to white
|
||||||
|
for col in range(row2.size()):
|
||||||
|
var book = _get_book_by_id(1, col)
|
||||||
|
var btn = book.get_node("BookButton") as TextureButton
|
||||||
|
btn.self_modulate = Color.WHITE
|
||||||
|
|
||||||
# 第三行正序或者倒序都可以
|
# 第三行正序或者倒序都可以
|
||||||
if not row_correct_status[2]:
|
if not row_correct_status[2]:
|
||||||
var row_success = true
|
var row_success = true
|
||||||
@ -232,6 +256,11 @@ func _check_answer() -> void:
|
|||||||
if row_success:
|
if row_success:
|
||||||
row_correct_status[2] = true
|
row_correct_status[2] = true
|
||||||
$SfxRowSuccess.play()
|
$SfxRowSuccess.play()
|
||||||
|
# set modulate back to white
|
||||||
|
for col in range(_row3.size()):
|
||||||
|
var book = _get_book_by_id(2, col)
|
||||||
|
var btn = book.get_node("BookButton") as TextureButton
|
||||||
|
btn.self_modulate = Color.WHITE
|
||||||
# 检查是否成功
|
# 检查是否成功
|
||||||
if row_correct_status[0] and row_correct_status[1] and row_correct_status[2]:
|
if row_correct_status[0] and row_correct_status[1] and row_correct_status[2]:
|
||||||
_success()
|
_success()
|
||||||
|
Loading…
Reference in New Issue
Block a user