fix: overlapping animations in different playables

This commit is contained in:
tiger tiger tiger 2026-01-18 21:23:37 +01:00
parent 3ed8896d3b
commit 517b1812ec
5 changed files with 35 additions and 18 deletions

View File

@ -43,6 +43,8 @@ func play() -> void:
print("CardBurner: ", len(cards)) print("CardBurner: ", len(cards))
await appear()
# 4. Wait for player to burn a card (or skip) # 4. Wait for player to burn a card (or skip)
print_debug("CardBurner: Waiting for player to burn a card...") print_debug("CardBurner: Waiting for player to burn a card...")
handle_direction_input(Vector2.UP) handle_direction_input(Vector2.UP)
@ -54,12 +56,14 @@ func play() -> void:
await $AnimationPlayer.animation_finished await $AnimationPlayer.animation_finished
print_debug("CardBurner: Sequence complete") print_debug("CardBurner: Sequence complete")
await vanish()
func handle_hover(card: Draggable) -> void: func handle_hover(card: Draggable) -> void:
if _submitted: return if _submitted: return
if not card is Card: return if not card is Card: return
selection = cards.find(card) selection = cards.find(card)
cursor.gamepad_mode = false
func handle_mouse_button(event: InputEventMouseButton, card: Card) -> void: func handle_mouse_button(event: InputEventMouseButton, card: Card) -> void:
@ -68,7 +72,9 @@ func handle_mouse_button(event: InputEventMouseButton, card: Card) -> void:
func _submit(card : Card): func _submit(card : Card):
_submitted = true _submitted = true
%ActionPrompt.visible = false
%SkipButton.visible = false %SkipButton.visible = false
await card.torch() await card.torch()
card_burned.emit() card_burned.emit()
@ -108,6 +114,7 @@ var selection: int:
card.highlighted = (selection == i) card.highlighted = (selection == i)
card.burn_state = Card.burned.SINGED if card.highlighted else Card.burned.NOT card.burn_state = Card.burned.SINGED if card.highlighted else Card.burned.NOT
if card.highlighted: if card.highlighted:
cursor.show()
cursor.gamepad_target = card.global_position + Vector2(-120, 150) cursor.gamepad_target = card.global_position + Vector2(-120, 150)
@ -119,11 +126,13 @@ func handle_direction_input(direction: Vector2) -> void:
match direction: match direction:
Vector2.UP: Vector2.UP:
cursor.show()
focus_cards = true focus_cards = true
cursor.visible = true cursor.visible = true
%SkipButton.release_focus() %SkipButton.release_focus()
selection = selection selection = selection
Vector2.DOWN: Vector2.DOWN:
cursor.hide()
focus_cards = false focus_cards = false
cursor.visible = false cursor.visible = false
%SkipButton.grab_focus() %SkipButton.grab_focus()
@ -133,5 +142,3 @@ func handle_direction_input(direction: Vector2) -> void:
Vector2.RIGHT: Vector2.RIGHT:
focus_cards = true focus_cards = true
selection += 1 selection += 1
if not focus_cards: cursor.gamepad_target += Vector2(0, 50)

View File

@ -91,10 +91,9 @@ grow_vertical = 2
script = ExtResource("1_copuj") script = ExtResource("1_copuj")
[node name="ColorRect" type="ColorRect" parent="."] [node name="ColorRect" type="ColorRect" parent="."]
visible = false
custom_minimum_size = Vector2(8192, 8192) custom_minimum_size = Vector2(8192, 8192)
layout_mode = 2 layout_mode = 2
color = Color(0, 0, 0, 0.3137255) color = Color(0, 0, 0, 0.5019608)
[node name="Control" type="Control" parent="."] [node name="Control" type="Control" parent="."]
layout_mode = 2 layout_mode = 2
@ -185,11 +184,11 @@ text = "Keep all thoughts"
[node name="CandleCursor" parent="." instance=ExtResource("3_l4ogr")] [node name="CandleCursor" parent="." instance=ExtResource("3_l4ogr")]
unique_name_in_owner = true unique_name_in_owner = true
position = Vector2(989, 1068) position = Vector2(1007, 1449)
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
self_modulate = Color(1, 1, 1, 0) self_modulate = Color(1, 1, 1, 0)
position = Vector2(954.99994, 545) position = Vector2(955, 545)
scale = Vector2(100, 100) scale = Vector2(100, 100)
texture = ExtResource("4_ckmi5") texture = ExtResource("4_ckmi5")

View File

@ -65,7 +65,7 @@ func expand() -> void:
func collapse() -> void: func collapse() -> void:
if not shown: return #TODO: test if not shown: return
shown = false shown = false
if tween and tween.is_valid(): tween.kill() if tween and tween.is_valid(): tween.kill()
tween = create_tween().set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_BACK) tween = create_tween().set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_BACK)
@ -111,6 +111,7 @@ func play_story() -> void:
Scenes.begin_sequence(playable.scene_id) Scenes.begin_sequence(playable.scene_id)
# Play the story # Play the story
await playable.appear()
await playable.play() await playable.play()
# Pick the cards if not already picked # Pick the cards if not already picked
@ -121,6 +122,7 @@ func play_story() -> void:
Scenes.end_sequence(playable.scene_id) # todo: maybe later? Scenes.end_sequence(playable.scene_id) # todo: maybe later?
# Hide the CanvasLayer when done # Hide the CanvasLayer when done
await playable.vanish()
canvas_layer.hide() canvas_layer.hide()
Scenes.player_enable.emit(true) Scenes.player_enable.emit(true)
@ -152,7 +154,6 @@ func play_burner() -> void:
func interact() -> void: func interact() -> void:
Scenes.player_enable.emit(false) Scenes.player_enable.emit(false)
shown = false
await collapse() await collapse()
collected = true collected = true

View File

@ -120,17 +120,11 @@ func try_scroll():
##tween.set_trans() ##tween.set_trans()
scroll_target = forward_target scroll_target = forward_target
func play(): func appear():
print_debug("StoryPlayable.gd: %s.play()" % self.name)
# There's an ugly glitch here.
hide() hide()
animation_player.play("RESET") animation_player.play("RESET")
await animation_player.animation_finished await animation_player.animation_finished
# Show ourselves before playing
get_parent().show() # Ensure visible Canvaslayer!
scroll_target = 0 scroll_target = 0
# FIXME: find out why this needs to be set to prevent scenes from being fully revealed # FIXME: find out why this needs to be set to prevent scenes from being fully revealed
@ -145,7 +139,11 @@ func play():
# Wait and get ready. # Wait and get ready.
await get_tree().process_frame await get_tree().process_frame
show() await super.appear()
func play():
print_debug("StoryPlayable.gd: %s.play()" % self.name)
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
# FIXME: Don't know how to do this. # FIXME: Don't know how to do this.
@ -168,7 +166,6 @@ func play():
await skip_control.proceed await skip_control.proceed
animation_player.play("vanish") animation_player.play("vanish")
await animation_player.animation_finished await animation_player.animation_finished
finished.emit() finished.emit()

View File

@ -2,7 +2,7 @@
class_name Playable class_name Playable
func _ready() -> void: func _ready() -> void:
pass hide()
## Awaitable that encapsulates the core interaction with this Playable ## Awaitable that encapsulates the core interaction with this Playable
func play() -> void: func play() -> void:
@ -12,3 +12,16 @@ func play() -> void:
func handle_hover(_area: Draggable): func handle_hover(_area: Draggable):
#prints("Playable[base].handle_hover", _area, _area.name) #prints("Playable[base].handle_hover", _area, _area.name)
pass pass
func appear():
self.modulate = Color.TRANSPARENT
show()
var tween := create_tween().set_ease(Tween.EASE_IN)
tween.tween_property(self, "modulate", Color.WHITE, 1.5)
await tween.finished
func vanish():
var tween := create_tween().set_ease(Tween.EASE_OUT)
tween.tween_property(self, "modulate", Color.TRANSPARENT, 1.5)
await tween.finished
hide()