fix hanafuda card lifetime

This commit is contained in:
Fabien Freling 2021-11-21 23:29:05 +01:00
parent ee9b4777cb
commit 4c7038dd4a
3 changed files with 13 additions and 9 deletions

View file

@ -33,9 +33,10 @@ enum Flower {
export var revealed: bool = true setget reveal
onready var _is_ready := true
# Called when the node enters the scene tree for the first time.
func _ready():
$Backside/TextureRect.rect_global_position = $"Backside/Border sprite".get_rect()
reveal(revealed)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -44,6 +45,10 @@ func _process(delta):
func reveal(new_reveal: bool):
revealed = new_reveal
if not _is_ready:
yield(self, "ready")
if revealed:
print("Reveal card")
$Frontside.show()

View file

@ -10,17 +10,16 @@ script = ExtResource( 1 )
revealed = false
[node name="Frontside" type="Sprite" parent="."]
visible = false
scale = Vector2( 0.2, 0.2 )
texture = ExtResource( 2 )
[node name="Backside" type="Node2D" parent="."]
visible = false
[node name="TextureRect" type="TextureRect" parent="Backside"]
margin_left = -91.0
margin_top = -155.0
margin_right = 809.0
margin_bottom = 1380.0
margin_left = -110.0
margin_top = -193.0
margin_right = 1000.0
margin_bottom = 1722.0
rect_scale = Vector2( 0.2, 0.2 )
texture = ExtResource( 4 )
stretch_mode = 2
@ -29,5 +28,4 @@ __meta__ = {
}
[node name="Border sprite" type="Sprite" parent="Backside"]
scale = Vector2( 0.2, 0.2 )
texture = ExtResource( 3 )

View file

@ -2,7 +2,7 @@
[ext_resource path="res://HanafudaCard.tscn" type="PackedScene" id=1]
[node name="Node2D" type="Node"]
[node name="Node" type="Node"]
[node name="Background" type="ColorRect" parent="."]
anchor_right = 1.0
@ -14,3 +14,4 @@ __meta__ = {
[node name="HanafudaCard" parent="." instance=ExtResource( 1 )]
position = Vector2( 205, 447 )
revealed = true