summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-25 23:40:32 +0200
committerrom <romangraef@gmail.com>2021-04-25 23:40:32 +0200
commit4a05e0f9ce36caf3e539a8321a36831bb9bba19d (patch)
tree46fd27ff4f97e3ecf4ec3387f3a0b67105195cd8
parentf80c497420dee7cd342284355e97686fcf131ce3 (diff)
downloadldjam48-4a05e0f9ce36caf3e539a8321a36831bb9bba19d.tar.gz
ldjam48-4a05e0f9ce36caf3e539a8321a36831bb9bba19d.tar.bz2
ldjam48-4a05e0f9ce36caf3e539a8321a36831bb9bba19d.zip
lvl1
-rw-r--r--components/button.gd20
-rw-r--r--scenes/introduction/check_mail.tscn1
-rw-r--r--scenes/levels/level1.gd2
-rw-r--r--scenes/levels/level1.tscn27
4 files changed, 35 insertions, 15 deletions
diff --git a/components/button.gd b/components/button.gd
index 734e048..6ed79be 100644
--- a/components/button.gd
+++ b/components/button.gd
@@ -1,6 +1,6 @@
extends Node2D
class_name ButtonTest
-export var text = "Hello, Button"
+export var text = "Hello, Button" setget _text
# Force a fixed width if != -1
export var fixed_width = -1
signal on_click()
@@ -30,13 +30,21 @@ const right_nohover = preload("res://textures/components/button/right.png")
const right_hover = preload("res://textures/components/button/right_hover.png")
const right_press = preload("res://textures/components/button/right_press.png")
-var label
+onready var label = Label.new()
func _ready():
- label = Label.new()
- label.text = text
label.theme = theme
add_child(label)
+ _text_changed()
+
+func _text(value):
+ text = value
+ _text_changed()
+
+func _text_changed():
+ label.text = ""
+ label.rect_size = Vector2(0,0)
+ label.text = text
label.rect_position = -label.rect_size / 2
var width = label.rect_size.x
if fixed_width > 0:
@@ -47,8 +55,8 @@ func _ready():
hitbox.shape = RectangleShape2D.new()
hitbox.shape.extents.y = 32
hitbox.shape.extents.x = right.position.x + right.scale.x * BASE_WIDTH / 2
-
-
+ update()
+ label.update()
func _on_ButtonTest_input_event(viewport, event, shape_idx):
if not (event is InputEventMouseButton):
diff --git a/scenes/introduction/check_mail.tscn b/scenes/introduction/check_mail.tscn
index eccdf90..b1b9fbb 100644
--- a/scenes/introduction/check_mail.tscn
+++ b/scenes/introduction/check_mail.tscn
@@ -96,6 +96,7 @@ align = 1
__meta__ = {
"_edit_use_anchors_": false
}
+
[connection signal="text_changed" from="password" to="." method="_on_password_text_changed"]
[connection signal="text_entered" from="password" to="." method="_on_password_text_entered"]
[connection signal="on_click" from="Log in" to="." method="_on_Log_in_on_click"]
diff --git a/scenes/levels/level1.gd b/scenes/levels/level1.gd
index 3386590..89dba81 100644
--- a/scenes/levels/level1.gd
+++ b/scenes/levels/level1.gd
@@ -10,6 +10,8 @@ var sequence_index = 0
func _ready():
for i in range(buttons.size()):
buttons[i].connect("on_click", self, "_on_AnyButton_click", [i])
+ buttons[i].text = str(i)
+ # buttons[i].visible = false
func _on_Any_button_click(btn_idx):
if btn_idx == order[sequence_index]:
diff --git a/scenes/levels/level1.tscn b/scenes/levels/level1.tscn
index fa40852..204374d 100644
--- a/scenes/levels/level1.tscn
+++ b/scenes/levels/level1.tscn
@@ -10,28 +10,37 @@ script = ExtResource( 1 )
[node name="ButtonHolder" type="Node2D" parent="."]
[node name="Button" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( -317.028, -134.015 )
+position = Vector2( -370.845, -187.832 )
+fixed_width = 30
[node name="Button2" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( 366.41, -3.20047 )
+position = Vector2( -256.483, 79.5727 )
+fixed_width = 30
[node name="Button3" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( 115.46, -187.408 )
+position = Vector2( 269.918, 246.07 )
+fixed_width = 30
[node name="Button4" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( 19.3514, 4.8085 )
+position = Vector2( -401.118, 15.6646 )
+fixed_width = 30
[node name="Button5" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( -258.295, 82.2293 )
+position = Vector2( -130.349, -46.5617 )
+fixed_width = 30
[node name="Button6" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( 142.157, 67.5461 )
+position = Vector2( -158.94, 224.207 )
+fixed_width = 30
[node name="Button7" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( -123.476, 198.36 )
+position = Vector2( 128.647, 79.5727 )
+fixed_width = 30
[node name="Button8" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( 50.0527, 262.433 )
+position = Vector2( 21.0123, -209.696 )
+fixed_width = 30
[node name="Button9" parent="ButtonHolder" instance=ExtResource( 2 )]
-position = Vector2( -147.504, -76.6167 )
+position = Vector2( 216.1, -39.8346 )
+fixed_width = 30