完成信件碎片拼凑游戏

This commit is contained in:
cakipaul 2025-02-10 18:59:19 +08:00
parent fea9462dbe
commit 311478a400
17 changed files with 254 additions and 54 deletions

BIN
asset/art/little_game/拼凑信件/信件碎片.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://cuyejl2kbp7y4" uid="uid://duxdnw1uhlpm5"
path="res://.godot/imported/信件碎片.png-c35bdb7240fb280003e7b3bca88b316c.ctex" path="res://.godot/imported/信件碎片.png-c35bdb7240fb280003e7b3bca88b316c.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c6rhstoc2p6gs"
path="res://.godot/imported/参考.png-395f2a02f849f78d29ad20c8f3e3bee3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://asset/art/little_game/拼凑信件/参考.png"
dest_files=["res://.godot/imported/参考.png-395f2a02f849f78d29ad20c8f3e3bee3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

BIN
asset/art/little_game/拼凑信件/完整信件.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@ -2,7 +2,7 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://dnjrdh1qnpony" uid="uid://glrm37tra7v5"
path="res://.godot/imported/完整信件.png-cfd076a390551cbdbbaeee723f1d98cc.ctex" path="res://.godot/imported/完整信件.png-cfd076a390551cbdbbaeee723f1d98cc.ctex"
metadata={ metadata={
"vram_texture": false "vram_texture": false

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://c2y4mpkygrmaf"
path="res://.godot/imported/桌面.png-84684fde2138421fbfd0a3bcb821c0ca.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://asset/art/little_game/拼凑信件/桌面.png"
dest_files=["res://.godot/imported/桌面.png-84684fde2138421fbfd0a3bcb821c0ca.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@ -1,6 +1,9 @@
keys,zh_CN,_character,_notes,_tags,en keys,zh_CN,_character,_notes,_tags,en
t89c0f4a8de,x年,,,, t89c0f4a8de,x年,,,,
t356af5308e,下午一点,,,, t356af5308e,下午一点,,,,
c01_信件全文,"小蝶:
【信件正文内容...】
【落款】",,,,
t344c97cf2c,据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。,,,, t344c97cf2c,据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。,,,,
tdb119a3714,有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。,,,, tdb119a3714,有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。,,,,
ta750647b12,《申报》,,,, ta750647b12,《申报》,,,,

1 keys zh_CN _character _notes _tags en
2 t89c0f4a8de x年
3 t356af5308e 下午一点
4 c01_信件全文 小蝶: 【信件正文内容...】 【落款】
5 t344c97cf2c 据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。
6 tdb119a3714 有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。
7 t344c97cf2c ta750647b12 据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 《申报》
8 tdb119a3714 t736cca4563 有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 民国五年一月十三日
9 ta750647b12 公寓告示正文_1 《申报》 公寓告示正文

View File

@ -3,6 +3,10 @@ x年 [ID:t89c0f4a8de]
下午一点 [ID:t356af5308e] 下午一点 [ID:t356af5308e]
=> END => END
~ c01_信件全文
小蝶:\n信件正文内容...\n落款 [ID:c01_信件全文]
=> END
~ c02_鼠疫海报 ~ c02_鼠疫海报
据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 [ID:t344c97cf2c] 据闻奉贤县分水墩又有七人染受鼠疫,病状可怖,闻医官药治无用,免职。 [ID:t344c97cf2c]
有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 [ID:tdb119a3714] 有地方人称鼠疫为妖邪作祟,甚为惊骇,一时人心惶惶,竟有聚众滋闹之事,政府以防疫事宜关系紧要,拟赴分水墩一带调查防疫事宜云。 [ID:tdb119a3714]

View File

@ -20,4 +20,3 @@ void vertex() {
// Move the vertex back to the original coordinate space. // Move the vertex back to the original coordinate space.
VERTEX = pos + center; VERTEX = pos + center;
} }

View File

@ -261,7 +261,9 @@ var prop_bag = preload("res://scene/prop/prop_bag.tscn")
func show_bag(): func show_bag():
get_node("/root/Main").add_child(prop_bag.instantiate()) pass
# 暂时不启用背包
# get_node("/root/Main").add_child(prop_bag.instantiate())
func quit_game(): func quit_game():

View File

@ -9,7 +9,7 @@
shader = ExtResource("3_er5jo") shader = ExtResource("3_er5jo")
shader_parameter/grey_scale = 0.33 shader_parameter/grey_scale = 0.33
[sub_resource type="Image" id="Image_7ef34"] [sub_resource type="Image" id="Image_8pfq8"]
data = { data = {
"data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
"format": "Lum8", "format": "Lum8",
@ -18,8 +18,8 @@ data = {
"width": 49 "width": 49
} }
[sub_resource type="ImageTexture" id="ImageTexture_uplae"] [sub_resource type="ImageTexture" id="ImageTexture_o5374"]
image = SubResource("Image_7ef34") image = SubResource("Image_8pfq8")
[node name="刮刮乐" type="Sprite2D"] [node name="刮刮乐" type="Sprite2D"]
position = Vector2(127, 138) position = Vector2(127, 138)
@ -34,6 +34,6 @@ offset_left = -24.0
offset_top = 6.0 offset_top = 6.0
offset_right = 25.0 offset_right = 25.0
offset_bottom = 24.0 offset_bottom = 24.0
texture = SubResource("ImageTexture_uplae") texture = SubResource("ImageTexture_o5374")
script = ExtResource("4_wp0ek") script = ExtResource("4_wp0ek")
area_size = Vector2(49, 18) area_size = Vector2(49, 18)

View File

@ -130,4 +130,6 @@ func _on_piano_interacted():
func show_interact_help(): func show_interact_help():
SceneManager.pop_center_notification(tr("ui_press_e")) pass
# 暂时无需使用背包系统
# SceneManager.pop_center_notification(tr("ui_press_e"))

View File

@ -174,7 +174,7 @@ func _check_answer() -> void:
for col in range(row1.size()): for col in range(row1.size()):
if row1[col] != col: if row1[col] != col:
return return
# 第二行正序或者倒序都可以 # 第二行需要正序排列
var row2 = current_answer[1] var row2 = current_answer[1]
var size2 = row2.size() var size2 = row2.size()
if row2[0] == 0: if row2[0] == 0:
@ -183,10 +183,11 @@ func _check_answer() -> void:
if row2[col] != col: if row2[col] != col:
return return
else: else:
# 倒序 return
for col in range(size2): # # 倒序
if row2[col] != size2 - 1 - col: # for col in range(size2):
return # if row2[col] != size2 - 1 - col:
# return
# 第三行正序或者倒序都可以 # 第三行正序或者倒序都可以
var _row3 = current_answer[2] var _row3 = current_answer[2]
var _size3 = _row3.size() var _size3 = _row3.size()

View File

@ -1,10 +1,17 @@
extends CanvasLayer extends CanvasLayer
@onready var container = %PartsContainer as GridContainer @onready var container = %PartsContainer
@onready var whole = %Whole as Sprite2D @onready var whole = %Whole
@onready var content_rect = %Content
# original: 152
var part_size = 110
var positions = []
# from part 0 to 3, rotated by 0, 90, 180, 270 degrees # from part 0 to 3, rotated by 0, 90, 180, 270 degrees
var rotations = [0, 0, 0, 0] var rotations = [0, 0, 0, 0]
var images = [] var images = []
var success = false
var selected := 0: var selected := 0:
set(value): set(value):
@ -14,16 +21,32 @@ var selected := 0:
func _ready() -> void: func _ready() -> void:
layer = GlobalConfig.LAYER_LITTLE_GAME layer = GlobalConfig.LAYER_LITTLE_GAME
for i in range(4): _setup()
var part = container.get_child(i)
part.pressed.connect(_select_part.bind(part))
images.append(part.texture_normal.get_image())
_shuffle() _shuffle()
_display_selected() _display_selected()
whole.visible = false content_rect.modulate.a = 0.0
content_rect.visible = true
%Label.text = tr("c01_信件全文")
SceneManager.pop_center_notification(tr("input_拼凑信件")) SceneManager.pop_center_notification(tr("input_拼凑信件"))
func _setup() -> void:
# 保存 whole 中的 4 个 part 的位置,然后从 whole 中移除,添加到 container 中
positions.clear()
images.clear()
for i in range(4):
var part = whole.get_child(0) as TextureButton
part.pressed.connect(_select_part.bind(part))
images.append(part.texture_normal.get_image())
positions.append(part.position)
# 从 whole 中移除,添加到 container 中
whole.remove_child(part)
container.add_child(part)
part.texture_click_mask = BitMap.new()
part.texture_click_mask.create_from_image_alpha(images[i])
_container_replace_children()
func _select_part(part) -> void: func _select_part(part) -> void:
selected = part.get_index() selected = part.get_index()
_display_selected() _display_selected()
@ -36,6 +59,14 @@ func _exchange_parts(a: int, b: int) -> void:
container.move_child(part_b, a) container.move_child(part_b, a)
# reassign answer # reassign answer
container.move_child(part_a, b) container.move_child(part_a, b)
_container_replace_children()
func _container_replace_children() -> void:
container.get_child(0).position = Vector2(0, 0)
container.get_child(1).position = Vector2(part_size, 0)
container.get_child(2).position = Vector2(0, part_size)
container.get_child(3).position = Vector2(part_size, part_size)
func _rotate_part(direction := 1) -> void: func _rotate_part(direction := 1) -> void:
@ -44,6 +75,7 @@ func _rotate_part(direction := 1) -> void:
rotations[id] = wrapi(rotations[id] + direction, 0, 4) rotations[id] = wrapi(rotations[id] + direction, 0, 4)
images[id].rotate_90(direction) images[id].rotate_90(direction)
part.texture_normal = ImageTexture.create_from_image(images[id]) part.texture_normal = ImageTexture.create_from_image(images[id])
part.texture_click_mask.create_from_image_alpha(images[id])
func _shuffle() -> void: func _shuffle() -> void:
@ -61,6 +93,8 @@ func _shuffle() -> void:
func _display_selected() -> void: func _display_selected() -> void:
if success:
return
for i in range(4): for i in range(4):
if i == selected: if i == selected:
container.get_child(i).modulate = Color(1, 1, 1) container.get_child(i).modulate = Color(1, 1, 1)
@ -69,18 +103,39 @@ func _display_selected() -> void:
func _check_answer() -> void: func _check_answer() -> void:
var success = true var _success = true
for i in range(4): for i in range(4):
var part = container.get_child(i) var part = container.get_child(i)
var id = int(str(part.name)) var id = int(str(part.name))
if rotations[id] != 0 or id != i: if rotations[id] != 0 or id != i:
success = false _success = false
if success: break
whole.visible = true success = _success
container.visible = false if _success:
# 从 container 中移除,添加到 whole 中
var tween = create_tween()
tween.tween_property(whole, "scale", Vector2.ONE, 1.0)
var diff = whole.position - container.position
whole.position = container.position
for i in range(4):
var part = container.get_child(0)
container.remove_child(part)
whole.add_child(part)
# 逐个恢复到原始 modulate
part.modulate = Color(1, 1, 1)
# 逐个移动到正确位置
tween.parallel().tween_property(part, "position", diff + positions[i], 1.0)
tween.tween_callback(_post_success)
func _post_success():
var tween = create_tween()
tween.parallel().tween_property(content_rect, "modulate:a", 1.0, 1.0)
func _unhandled_input(event: InputEvent) -> void: func _unhandled_input(event: InputEvent) -> void:
if success:
return
var handled = false var handled = false
if event.is_action_pressed("up"): if event.is_action_pressed("up"):
if selected > 1: if selected > 1:
@ -106,6 +161,7 @@ func _unhandled_input(event: InputEvent) -> void:
_rotate_part() _rotate_part()
handled = true handled = true
if handled: if handled:
$SfxMove.play()
_display_selected() _display_selected()
_check_answer() _check_answer()
get_viewport().set_input_as_handled() get_viewport().set_input_as_handled()

View File

@ -1,31 +1,37 @@
[gd_scene load_steps=8 format=3 uid="uid://bp3tkos1ufjcl"] [gd_scene load_steps=10 format=3 uid="uid://bp3tkos1ufjcl"]
[ext_resource type="Script" path="res://scene/little_game/拼凑信件.gd" id="1_cifku"] [ext_resource type="Script" path="res://scene/little_game/拼凑信件.gd" id="1_cifku"]
[ext_resource type="Texture2D" uid="uid://dnjrdh1qnpony" path="res://asset/art/little_game/拼凑信件/完整信件.png" id="3_uenrm"] [ext_resource type="Texture2D" uid="uid://c2y4mpkygrmaf" path="res://asset/art/little_game/拼凑信件/桌面.png" id="2_0fxwt"]
[ext_resource type="PackedScene" uid="uid://c85t6stvytvjn" path="res://scene/entity/general/sfx.tscn" id="2_yetjt"]
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_5u07c"] [ext_resource type="AudioStream" uid="uid://byjcmxy5crce5" path="res://asset/audio/sfx/ui/纸条.mp3" id="3_0asyu"]
load_path = "res://.godot/imported/信件碎片.png-c35bdb7240fb280003e7b3bca88b316c.ctex" [ext_resource type="Texture2D" uid="uid://duxdnw1uhlpm5" path="res://asset/art/little_game/拼凑信件/信件碎片.png" id="3_mjf3s"]
[sub_resource type="AtlasTexture" id="AtlasTexture_4e0jv"] [sub_resource type="AtlasTexture" id="AtlasTexture_4e0jv"]
atlas = SubResource("CompressedTexture2D_5u07c") atlas = ExtResource("3_mjf3s")
region = Rect2(29, 16, 75, 80) region = Rect2(140, 8, 152, 152)
[sub_resource type="AtlasTexture" id="AtlasTexture_qxu7b"] [sub_resource type="AtlasTexture" id="AtlasTexture_qxu7b"]
atlas = SubResource("CompressedTexture2D_5u07c") atlas = ExtResource("3_mjf3s")
region = Rect2(104, 16, 72, 80) region = Rect2(280, 9, 152, 152)
margin = Rect2(0, 3, 0, 3)
[sub_resource type="AtlasTexture" id="AtlasTexture_mbck6"] [sub_resource type="AtlasTexture" id="AtlasTexture_mbck6"]
atlas = SubResource("CompressedTexture2D_5u07c") atlas = ExtResource("3_mjf3s")
region = Rect2(24, 120, 72, 72) region = Rect2(140, 180, 152, 152)
margin = Rect2(8, 12, 8, 12)
[sub_resource type="AtlasTexture" id="AtlasTexture_5dpsb"] [sub_resource type="AtlasTexture" id="AtlasTexture_5dpsb"]
atlas = SubResource("CompressedTexture2D_5u07c") atlas = ExtResource("3_mjf3s")
region = Rect2(104, 104, 80, 88) region = Rect2(280, 200, 152, 152)
[node name="拼凑信件" type="CanvasLayer"] [node name="拼凑信件" type="CanvasLayer"]
layer = 5 layer = 5
script = ExtResource("1_cifku") script = ExtResource("1_cifku")
[node name="SfxMove" parent="." instance=ExtResource("2_yetjt")]
stream = ExtResource("3_0asyu")
file = "纸条.mp3"
[node name="Control" type="Control" parent="."] [node name="Control" type="Control" parent="."]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@ -42,34 +48,93 @@ anchor_right = 1.0
anchor_bottom = 0.5 anchor_bottom = 0.5
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
texture = ExtResource("2_0fxwt")
[node name="Whole" type="Sprite2D" parent="Control"] [node name="PartsContainer" type="Control" parent="Control"]
unique_name_in_owner = true unique_name_in_owner = true
visible = false anchors_preset = 0
position = Vector2(263, 161) offset_left = 170.0
texture = ExtResource("3_uenrm") offset_top = 57.0
offset_right = 170.0
offset_bottom = 57.0
scale = Vector2(0.8, 0.8)
mouse_filter = 2
[node name="PartsContainer" type="GridContainer" parent="Control"] [node name="Whole" type="Control" parent="Control"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 0 anchors_preset = 0
offset_left = 206.0 offset_left = 242.0
offset_top = 72.0 offset_top = 76.0
offset_right = 365.0 offset_right = 282.0
offset_bottom = 244.0 offset_bottom = 116.0
columns = 2 scale = Vector2(0.8, 0.8)
mouse_filter = 2
[node name="0" type="TextureButton" parent="Control/PartsContainer"] [node name="0" type="TextureButton" parent="Control/Whole"]
layout_mode = 2 layout_mode = 2
offset_left = -57.5
offset_top = -27.5
offset_right = 94.5
offset_bottom = 124.5
grow_horizontal = 2
grow_vertical = 2
texture_normal = SubResource("AtlasTexture_4e0jv") texture_normal = SubResource("AtlasTexture_4e0jv")
[node name="1" type="TextureButton" parent="Control/PartsContainer"] [node name="1" type="TextureButton" parent="Control/Whole"]
layout_mode = 2 layout_mode = 2
offset_left = -12.5
offset_top = -26.25
offset_right = 139.5
offset_bottom = 128.75
grow_horizontal = 2
grow_vertical = 2
texture_normal = SubResource("AtlasTexture_qxu7b") texture_normal = SubResource("AtlasTexture_qxu7b")
[node name="2" type="TextureButton" parent="Control/PartsContainer"] [node name="2" type="TextureButton" parent="Control/Whole"]
layout_mode = 2 layout_mode = 2
offset_left = -66.25
offset_top = 48.75
offset_right = 93.75
offset_bottom = 212.75
grow_horizontal = 2
grow_vertical = 2
texture_normal = SubResource("AtlasTexture_mbck6") texture_normal = SubResource("AtlasTexture_mbck6")
[node name="3" type="TextureButton" parent="Control/PartsContainer"] [node name="3" type="TextureButton" parent="Control/Whole"]
layout_mode = 2 layout_mode = 2
offset_left = -20.0
offset_top = 72.5
offset_right = 132.0
offset_bottom = 224.5
grow_horizontal = 2
grow_vertical = 2
texture_normal = SubResource("AtlasTexture_5dpsb") texture_normal = SubResource("AtlasTexture_5dpsb")
[node name="Content" type="ColorRect" parent="Control"]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
color = Color(0, 0, 0, 0.682353)
[node name="Label" type="Label" parent="Control/Content"]
unique_name_in_owner = true
custom_minimum_size = Vector2(100, 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 = -20.0
offset_top = -7.5
offset_right = 20.0
offset_bottom = 7.5
grow_horizontal = 2
grow_vertical = 2
text = "Content"