Skip to content

Commit 34c6d88

Browse files
LifeHckrQuinn-Hub
andauthored
Add Credits Scene (#203)
* Update: Rough Draft of Credits Changelog -> Changed redirect to options menu scene to my "CreditsOptionTest" scene to represent how we can use the credits button in the options. -> Added functionality of entering and exiting the credits menu -> Made a rough draft of the credits menu * Update: Scrolling Credits Menu Changelog -> Added vertical scrolling and fadeout -> Reused assets to make a nice relaxing background. * Clean up credits scene and script --------- Co-authored-by: Quinn-Hub <56490493+Quinn-Hub@users.noreply.github.com>
1 parent bc6f004 commit 34c6d88

File tree

4 files changed

+162
-0
lines changed

4 files changed

+162
-0
lines changed

Scenes/UI/Options/Credits.tscn

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
[gd_scene load_steps=4 format=3 uid="uid://dgjmb0wllsj41"]
2+
3+
[ext_resource type="Script" uid="uid://drt21hext7pm2" path="res://Scenes/UI/Options/Scripts/CreditsMenu.cs" id="1_n36fd"]
4+
[ext_resource type="Theme" uid="uid://d37e3tpsbxwak" path="res://Scenes/UI/Assets/GeneralTheme.tres" id="3_agb8c"]
5+
[ext_resource type="PackedScene" uid="uid://dfevfib11kou1" path="res://Scenes/ChartViewport/ChartViewport.tscn" id="3_ch0mg"]
6+
7+
[node name="Credits" type="Control" node_paths=PackedStringArray("CreditsText", "_returnButton")]
8+
process_mode = 3
9+
layout_mode = 3
10+
anchors_preset = 15
11+
anchor_right = 1.0
12+
anchor_bottom = 1.0
13+
grow_horizontal = 2
14+
grow_vertical = 2
15+
script = ExtResource("1_n36fd")
16+
CreditsText = NodePath("Node2D/Label")
17+
ScrollSpeed = 24.0
18+
RestartPositionY = 400.0
19+
_returnButton = NodePath("Return Button")
20+
21+
[node name="Node2D2" type="Node2D" parent="."]
22+
position = Vector2(80, -12.26)
23+
scale = Vector2(2.255, 2.01)
24+
25+
[node name="SubViewport" parent="Node2D2" instance=ExtResource("3_ch0mg")]
26+
offset_left = -57.1486
27+
offset_top = 5.0
28+
offset_right = 422.851
29+
offset_bottom = 185.0
30+
31+
[node name="Node2D" type="Node2D" parent="."]
32+
33+
[node name="Label" type="Label" parent="Node2D"]
34+
offset_left = 217.0
35+
offset_top = -3.0
36+
offset_right = 467.0
37+
offset_bottom = 410.0
38+
text = "Credits
39+
40+
Programmers
41+
Jarod Spanger: Project Lead
42+
Connor Lowe
43+
Raul Mojarro
44+
Thomas Wessel
45+
Michael Quinn
46+
47+
Artists
48+
Ares Atlas
49+
Evelyn Fu
50+
Emily Wen
51+
52+
Sound
53+
Sam Meyer: Composer"
54+
horizontal_alignment = 1
55+
56+
[node name="Return Button" type="Button" parent="."]
57+
layout_mode = 2
58+
offset_left = 570.0
59+
offset_top = 314.0
60+
offset_right = 631.0
61+
offset_bottom = 351.0
62+
theme = ExtResource("3_agb8c")
63+
text = "Return"
64+
icon_alignment = 1
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
using System;
2+
using FunkEngine;
3+
using Godot;
4+
5+
public partial class CreditsMenu : Control, IFocusableMenu
6+
{
7+
public static readonly string LoadPath = "res://Scenes/UI/Options/Credits.tscn";
8+
9+
[Export]
10+
public Label CreditsText;
11+
12+
[Export]
13+
public float ScrollSpeed = 50f;
14+
15+
public float FadeStartY = 0;
16+
public float FadeEndY = -400f;
17+
18+
[Export]
19+
public float RestartPositionY = 800f;
20+
21+
[Export]
22+
private Button _returnButton;
23+
24+
public IFocusableMenu Prev { get; set; }
25+
26+
public override void _Ready()
27+
{
28+
if (CreditsText != null)
29+
{
30+
CreditsText.Position = new Vector2(CreditsText.Position.X, RestartPositionY);
31+
FadeEndY = -CreditsText.Size.Y;
32+
}
33+
_returnButton.Pressed += ReturnToPrev;
34+
_returnButton.GrabFocus();
35+
}
36+
37+
public void ResumeFocus()
38+
{
39+
ProcessMode = ProcessModeEnum.Inherit;
40+
_returnButton.GrabFocus();
41+
}
42+
43+
public void PauseFocus()
44+
{
45+
ProcessMode = ProcessModeEnum.Disabled;
46+
}
47+
48+
public void OpenMenu(IFocusableMenu prev)
49+
{
50+
Prev = prev;
51+
Prev.PauseFocus();
52+
_returnButton.GrabFocus();
53+
}
54+
55+
public void ReturnToPrev()
56+
{
57+
Prev.ResumeFocus();
58+
QueueFree();
59+
}
60+
61+
public override void _Input(InputEvent @event)
62+
{
63+
if (@event.IsActionPressed("ui_cancel"))
64+
{
65+
ReturnToPrev();
66+
GetViewport().SetInputAsHandled();
67+
}
68+
}
69+
70+
public override void _Process(double delta)
71+
{
72+
if (CreditsText == null)
73+
return;
74+
75+
CreditsText.Position += Vector2.Up * (float)(ScrollSpeed * delta);
76+
77+
float alpha = Mathf.Clamp(
78+
1 - (CreditsText.GlobalPosition.Y - FadeStartY) / (FadeEndY - FadeStartY),
79+
0,
80+
1
81+
);
82+
CreditsText.Modulate = new Color(1, 1, 1, alpha);
83+
84+
if (CreditsText.GlobalPosition.Y < -CreditsText.Size.Y)
85+
{
86+
CreditsText.Position = new Vector2(CreditsText.Position.X, RestartPositionY);
87+
}
88+
}
89+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uid://drt21hext7pm2

Scenes/UI/Options/Scripts/OptionsMenu.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,12 @@ private void OpenHowToPlay()
124124
AddChild(howtoPlay);
125125
howtoPlay.OpenMenu(this);
126126
}
127+
128+
private void OpenCredits()
129+
{
130+
CreditsMenu creditsMenu = GD.Load<PackedScene>(CreditsMenu.LoadPath)
131+
.Instantiate<CreditsMenu>();
132+
AddChild(creditsMenu);
133+
creditsMenu.OpenMenu(this);
134+
}
127135
}

0 commit comments

Comments
 (0)