From c6ec75e7688f2388bae38fbdfe87149b0ae5a049 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Mon, 6 Dec 2021 23:44:23 +0100 Subject: [PATCH] display Deck --- Deck.gd | 13 ++++++++++++- HanafudaCard.gd | 3 ++- Main.tscn | 3 ++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Deck.gd b/Deck.gd index aee01bb..71a5786 100644 --- a/Deck.gd +++ b/Deck.gd @@ -1,4 +1,4 @@ -extends Node +extends Node2D var HanafudaCard = preload("res://HanafudaCard.tscn") @@ -64,7 +64,18 @@ onready var cards = [ HanafudaCard.instance().init_card(Enums.Month.DECEMBER, Enums.Type.SCRAP_3), ] +var card_order = [] + # Called when the node enters the scene tree for the first time. func _ready() -> void: + init_card_order() for c in cards: add_child(c) + + var card: HanafudaCard = cards[0] + card.reveal(true) + +func init_card_order() -> void: + card_order.resize(cards.size()) + for i in range(cards.size()): + card_order[i] = i diff --git a/HanafudaCard.gd b/HanafudaCard.gd index cfac459..c58893b 100644 --- a/HanafudaCard.gd +++ b/HanafudaCard.gd @@ -14,9 +14,10 @@ func _ready() -> void: $Frontside.texture = load(texture_path) reveal(revealed) -func init_card(month_: int, type_: int) -> void: +func init_card(month_: int, type_: int) -> HanafudaCard: month = month_ type = type_ + return self func card_texture() -> String: var m := "" diff --git a/Main.tscn b/Main.tscn index 39390ab..7e07080 100644 --- a/Main.tscn +++ b/Main.tscn @@ -16,8 +16,9 @@ __meta__ = { } [node name="HanafudaCard" parent="." instance=ExtResource( 1 )] +visible = false position = Vector2( 205, 447 ) month = 2 -[node name="Deck" type="Node" parent="."] +[node name="Deck" type="Node2D" parent="."] script = ExtResource( 3 )