Add animations to popups, points, songs, the winner and the tabs (#48)
Popups fade in while growing and close the reverse way, with the backdrop fading along. The winner gets confetti, bouncing pictures and a score graph that draws itself from the left. Filtered statistics cards and search rows fade in, the tabs slide in from their side, and every button bounces on hover and click (ButtonBounce, now added to all buttons). In the player list the score pops on every point, the first point flashes the row, and a player on match point glows with a "Match point!" tag. A song starting fades in the title, flashes its row (kept across list rebuilds) and pops the play button. Common/anim.gd holds the helpers. A saved "Reduce animations" switch in Settings turns all movement off; the tests use it. The flash colours are theme colours (Palette first_point, match_point, flash) in every theme. Closes #48 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae231975bd
commit
0fc3be79e1
31 files changed
+1510
-639
No files matched your search
+52
-1
@@ -2,7 +2,12 @@ class_name WinnerPopup
|
||||
extends BasePopup
|
||||
## Shows who won, with their character, where the other players placed, and how the game
|
||||
## went: a graph of everyone's score after each song and a few facts about it.
|
||||
##
|
||||
## The winners' pictures bounce in, confetti falls over the panel and the graph draws its
|
||||
## lines from left to right. See [Anim].
|
||||
|
||||
## How many pieces of confetti fly when someone wins.
|
||||
const CONFETTI_AMOUNT: int = 160
|
||||
## Size of the coloured square in front of each name in the legend.
|
||||
const LEGEND_SQUARE_SIZE: Vector2 = Vector2(14, 14)
|
||||
|
||||
@@ -29,7 +34,7 @@ func show_winner(winner: PlayerObject) -> void:
|
||||
## Shows [param winners], who share the top score, with everyone else's placing below.
|
||||
## Tied players get the same placing. With no players, it says the quiz is over.
|
||||
func show_winners(winners: Array[PlayerObject]) -> void:
|
||||
visible = true
|
||||
open()
|
||||
winner_label.text = winners_text(winners)
|
||||
_show_pictures(winners)
|
||||
|
||||
@@ -49,6 +54,7 @@ func show_winners(winners: Array[PlayerObject]) -> void:
|
||||
players_list.add_child(label)
|
||||
|
||||
show_history(ScoreHistory.from_playlist(Settings.player_array))
|
||||
_celebrate()
|
||||
|
||||
|
||||
## The headline for [param winners], e.g. "Crono won with 5 points!!" or "Crono and
|
||||
@@ -80,6 +86,51 @@ static func placing(player: PlayerObject) -> int:
|
||||
return place
|
||||
|
||||
|
||||
# The winners' pictures bounce in, confetti flies and the graph draws itself
|
||||
func _celebrate() -> void:
|
||||
for picture: Node in winner_picture.get_parent().get_children():
|
||||
if picture is TextureRect && (picture as TextureRect).visible:
|
||||
Anim.bounce_in(picture)
|
||||
score_graph.draw_lines_in()
|
||||
if Anim.enabled():
|
||||
_throw_confetti()
|
||||
|
||||
|
||||
# A burst of confetti from the top of the panel, in the players' graph colours
|
||||
func _throw_confetti() -> void:
|
||||
var old: Node = winner_panel.get_node_or_null("Confetti")
|
||||
if old != null:
|
||||
old.free()
|
||||
var confetti: CPUParticles2D = CPUParticles2D.new()
|
||||
confetti.name = "Confetti"
|
||||
confetti.position = Vector2(winner_panel.size.x / 2, 0)
|
||||
confetti.emission_shape = CPUParticles2D.EMISSION_SHAPE_RECTANGLE
|
||||
confetti.emission_rect_extents = Vector2(winner_panel.size.x / 2, 4)
|
||||
confetti.amount = CONFETTI_AMOUNT
|
||||
confetti.lifetime = 2.6
|
||||
confetti.one_shot = true
|
||||
confetti.explosiveness = 0.85
|
||||
confetti.direction = Vector2.DOWN
|
||||
confetti.spread = 35.0
|
||||
confetti.gravity = Vector2(0, 260)
|
||||
confetti.initial_velocity_min = 80.0
|
||||
confetti.initial_velocity_max = 260.0
|
||||
confetti.angular_velocity_min = -360.0
|
||||
confetti.angular_velocity_max = 360.0
|
||||
confetti.scale_amount_min = 5.0
|
||||
confetti.scale_amount_max = 9.0
|
||||
var colours: Gradient = Gradient.new()
|
||||
colours.interpolation_mode = Gradient.GRADIENT_INTERPOLATE_CONSTANT
|
||||
colours.offsets = PackedFloat32Array()
|
||||
colours.colors = PackedColorArray()
|
||||
for i: int in 7:
|
||||
colours.add_point(i / 7.0, score_graph.player_color(i))
|
||||
confetti.color_initial_ramp = colours
|
||||
confetti.finished.connect(confetti.queue_free)
|
||||
winner_panel.add_child(confetti)
|
||||
confetti.emitting = true
|
||||
|
||||
|
||||
# One picture per winner, next to each other
|
||||
func _show_pictures(winners: Array[PlayerObject]) -> void:
|
||||
var header: Node = winner_picture.get_parent()
|
||||
|
||||
Reference in new issue
Block a user