theming cards and randomising card backgrounds

This commit is contained in:
betalars 2023-05-18 09:27:59 +02:00
parent 59aadd00a4
commit 12d6717736
4 changed files with 188 additions and 48 deletions

View File

@ -15,7 +15,7 @@ func _ready():
if not Engine.is_editor_hint() and is_inside_tree():
for postit in self.get_children(false):
self.compatible_postits.append(postit as PostIt)
$BackgroundSprite.frame = randi() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
$Label.text = self.text
func _process(delta: float) -> void:

View File

@ -1,42 +1,84 @@
[gd_scene load_steps=5 format=3 uid="uid://dy5rd437h5hsw"]
[gd_scene load_steps=10 format=3 uid="uid://dy5rd437h5hsw"]
[ext_resource type="Script" path="res://logic-scenes/board/card.gd" id="1_emip0"]
[ext_resource type="Texture2D" uid="uid://ccncau1yfqyuf" path="res://logic-scenes/board/cardsheet.png" id="2_x4r1c"]
[ext_resource type="Texture2D" uid="uid://sv0nhkkur1tt" path="res://logic-scenes/board/card-textures/cardsheet.png" id="2_ioijn"]
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_rktsa"]
[sub_resource type="AtlasTexture" id="AtlasTexture_olf16"]
atlas = ExtResource("2_x4r1c")
region = Rect2(49, 472.5, 528, 366)
[sub_resource type="AtlasTexture" id="AtlasTexture_ykk13"]
atlas = ExtResource("2_ioijn")
region = Rect2(0, 0, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_l43eo"]
atlas = ExtResource("2_ioijn")
region = Rect2(600, 0, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_x2vcn"]
atlas = ExtResource("2_ioijn")
region = Rect2(0, 440, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_e7401"]
atlas = ExtResource("2_ioijn")
region = Rect2(600, 440, 600, 440)
[sub_resource type="AtlasTexture" id="AtlasTexture_j7wh6"]
atlas = ExtResource("2_ioijn")
region = Rect2(0, 880, 600, 440)
[sub_resource type="SpriteFrames" id="SpriteFrames_ckivt"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ykk13")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_l43eo")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x2vcn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e7401")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j7wh6")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="card" type="Control"]
layout_mode = 3
anchor_right = 0.179
anchor_bottom = 0.239
offset_right = 0.23999
offset_bottom = -0.119995
grow_horizontal = 2
grow_vertical = 2
anchors_preset = 0
offset_left = -150.0
offset_top = -110.0
offset_right = 150.0
offset_bottom = 110.0
focus_mode = 2
script = ExtResource("1_emip0")
compatible_postits = Array[Resource("res://logic-scenes/board/post-it.gd")]([null, null, null])
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 528.0
offset_bottom = 366.0
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
position = Vector2(150, 110)
scale = Vector2(0.6, 0.6)
texture = SubResource("AtlasTexture_olf16")
sprite_frames = SubResource("SpriteFrames_ckivt")
frame_progress = 0.407616
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 22.0
offset_top = 35.0
offset_right = 298.0
offset_bottom = 215.0
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -127.0
offset_top = -82.5
offset_right = 127.0
offset_bottom = 82.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_rktsa")
theme_type_variation = &"card_text"
text = "this is a test
with a second line"
autowrap_mode = 3
[node name="postit anchor" type="Control" parent="."]

View File

@ -7,11 +7,13 @@ class_name PostIt
set (value):
if is_inside_tree() or Engine.is_editor_hint():
$Label.text = value
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
text = value
@export var voice_line: AudioStream = null
func _ready() -> void:
$Label.text = self.text
$BackgroundSprite.frame = text.hash() % $BackgroundSprite.sprite_frames.get_frame_count($BackgroundSprite.animation)
func _process(delta: float) -> void:
pass

View File

@ -1,38 +1,134 @@
[gd_scene load_steps=4 format=3 uid="uid://vkcdj8c3ytbq"]
[gd_scene load_steps=17 format=3 uid="uid://vkcdj8c3ytbq"]
[ext_resource type="Script" path="res://logic-scenes/board/post-it.gd" id="1_yvh5n"]
[ext_resource type="Texture2D" uid="uid://dq7jm5ufknbb6" path="res://vfx/lens-flare-particle.png" id="2_jr288"]
[ext_resource type="Texture2D" uid="uid://c8ckkjmdegyis" path="res://logic-scenes/board/card-textures/postitsheet.png" id="2_j17jn"]
[ext_resource type="Theme" uid="uid://b056fn288p8ha" path="res://logic-scenes/themes/messy.theme" id="3_hu2as"]
[sub_resource type="LabelSettings" id="LabelSettings_vm4x4"]
font_size = 30
outline_size = 10
outline_color = Color(0, 0, 0, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_nj16s"]
atlas = ExtResource("2_j17jn")
region = Rect2(0, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_23tiq"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_aomh0"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_n3svg"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 0, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_tfg7a"]
atlas = ExtResource("2_j17jn")
region = Rect2(0, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_dtics"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_e0ocs"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_bpwg2"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 220, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_xaxol"]
atlas = ExtResource("2_j17jn")
region = Rect2(0, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_ifitb"]
atlas = ExtResource("2_j17jn")
region = Rect2(500, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_6slhe"]
atlas = ExtResource("2_j17jn")
region = Rect2(1000, 440, 500, 220)
[sub_resource type="AtlasTexture" id="AtlasTexture_4tk5m"]
atlas = ExtResource("2_j17jn")
region = Rect2(1500, 440, 500, 220)
[sub_resource type="SpriteFrames" id="SpriteFrames_2amsi"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_nj16s")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_23tiq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aomh0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_n3svg")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tfg7a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_dtics")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_e0ocs")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bpwg2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xaxol")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ifitb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_6slhe")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_4tk5m")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="post-it" type="Control"]
layout_mode = 3
anchor_right = 0.187
anchor_bottom = 0.239
offset_right = -124.28
offset_bottom = -100.12
grow_horizontal = 2
grow_vertical = 2
anchors_preset = 0
offset_left = -150.0
offset_top = -50.0
offset_right = 150.0
offset_bottom = 50.0
focus_mode = 2
script = ExtResource("1_yvh5n")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 0
offset_right = 135.0
offset_bottom = 138.0
texture = ExtResource("2_jr288")
[node name="BackgroundSprite" type="AnimatedSprite2D" parent="."]
position = Vector2(150, 50)
scale = Vector2(0.65, 0.65)
sprite_frames = SubResource("SpriteFrames_2amsi")
frame_progress = 0.366837
[node name="Label" type="Label" parent="."]
layout_mode = 0
offset_left = 6.0
offset_top = 7.0
offset_right = 131.0
offset_bottom = 134.0
focus_mode = 2
label_settings = SubResource("LabelSettings_vm4x4")
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -139.5
offset_top = -50.0
offset_right = 137.5
offset_bottom = 47.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("3_hu2as")
theme_type_variation = &"card_text"
text = "Test"
vertical_alignment = 1
autowrap_mode = 3
[connection signal="focus_entered" from="." to="." method="_on_focus_entered"]