-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New node ShiftingLabel for visualizing consonant/vowel pools
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Godot; | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
public partial class ShiftingLabel : Label | ||
{ | ||
private Random _random; | ||
|
||
// Strings to shift through | ||
public List<string> Values; | ||
|
||
public override void _Ready() | ||
{ | ||
_random = new Random(); | ||
this.Values = new List<string>(); | ||
this.GetNode<Timer>("Timer").Start(); | ||
} | ||
|
||
// Randomly select a value from the list | ||
// and set the value of this label | ||
public void Shift() | ||
{ | ||
if (this.Values.Count > 0) | ||
{ | ||
var index = _random.Next(0, this.Values.Count); | ||
this.Text = this.Values[index].ToUpper(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://cr4njnftd3faq"] | ||
|
||
[ext_resource type="Script" path="res://ShiftingLabel.cs" id="1_53b72"] | ||
|
||
[sub_resource type="LabelSettings" id="LabelSettings_0r5f7"] | ||
font_size = 35 | ||
|
||
[node name="ShiftingLabel" type="Label"] | ||
offset_right = 40.0 | ||
offset_bottom = 23.0 | ||
text = "X" | ||
label_settings = SubResource("LabelSettings_0r5f7") | ||
horizontal_alignment = 1 | ||
vertical_alignment = 1 | ||
script = ExtResource("1_53b72") | ||
|
||
[node name="Timer" type="Timer" parent="."] | ||
wait_time = 0.2 | ||
autostart = true | ||
|
||
[connection signal="timeout" from="Timer" to="." method="Shift"] |