FaC grid container
This commit is contained in:
parent
75603094bb
commit
3232182a9f
8 changed files with 67 additions and 51 deletions
|
@ -1,11 +0,0 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b2u1412b6fugp"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cignc2wdaxuro" path="res://scenes/find_a_couple/level_handler.tscn" id="1_hr0pl"]
|
||||
[ext_resource type="PackedScene" uid="uid://blfx4g52uaopo" path="res://scenes/find_a_couple/tile.tscn" id="2_0am66"]
|
||||
|
||||
[node name="Level" type="Node2D"]
|
||||
|
||||
[node name="Control" parent="." instance=ExtResource("1_hr0pl")]
|
||||
|
||||
[node name="Tile" parent="." instance=ExtResource("2_0am66")]
|
||||
position = Vector2(239, 223)
|
|
@ -1,4 +1,6 @@
|
|||
[gd_scene format=3 uid="uid://cignc2wdaxuro"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cignc2wdaxuro"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://exbrdfhk0bou" path="res://scenes/find_a_couple/tile_grid.tscn" id="1_85msg"]
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
|
@ -16,7 +18,7 @@ offset_bottom = 720.0
|
|||
mouse_filter = 1
|
||||
color = Color(0.787759, 0.787759, 0.787759, 1)
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
[node name="Label" type="Label" parent="ColorRect"]
|
||||
layout_mode = 0
|
||||
offset_right = 99.0
|
||||
offset_bottom = 69.0
|
||||
|
@ -25,3 +27,10 @@ text = "1:00"
|
|||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
justification_flags = 162
|
||||
|
||||
[node name="GridContainer" parent="ColorRect" instance=ExtResource("1_85msg")]
|
||||
layout_mode = 0
|
||||
offset_left = 515.0
|
||||
offset_top = 217.0
|
||||
offset_right = 765.0
|
||||
offset_bottom = 467.0
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
uid://c6slf3hspqeef
|
|
@ -1,26 +0,0 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://blfx4g52uaopo"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bsj2xqsrkncfw" path="res://assets/find_a_couple/envelope.png" id="1_dgwjn"]
|
||||
[ext_resource type="Script" uid="uid://c6slf3hspqeef" path="res://scenes/find_a_couple/tile.gd" id="1_kwys0"]
|
||||
[ext_resource type="Texture2D" uid="uid://yn1hkayub20t" path="res://assets/find_a_couple/back.png" id="2_npifk"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_npifk"]
|
||||
size = Vector2(102, 102)
|
||||
|
||||
[node name="Tile" type="Area2D"]
|
||||
script = ExtResource("1_kwys0")
|
||||
front_texture = ExtResource("1_dgwjn")
|
||||
back_texture = ExtResource("2_npifk")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_npifk")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.2, 0.2)
|
||||
texture = ExtResource("1_dgwjn")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="input_event" from="." to="." method="_on_input_event"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
22
scenes/find_a_couple/tile_btn.tscn
Normal file
22
scenes/find_a_couple/tile_btn.tscn
Normal file
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://lu353vx1qhnw"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bsj2xqsrkncfw" path="res://assets/find_a_couple/envelope.png" id="1_hsyko"]
|
||||
[ext_resource type="Script" uid="uid://dj8d1k52lircu" path="res://scripts/find_a_couple/tile.gd" id="2_4covg"]
|
||||
[ext_resource type="Texture2D" uid="uid://yn1hkayub20t" path="res://assets/find_a_couple/back.png" id="3_4covg"]
|
||||
|
||||
[node name="TextureButton" type="TextureButton"]
|
||||
offset_right = 100.0
|
||||
offset_bottom = 100.0
|
||||
pivot_offset = Vector2(50, 50)
|
||||
texture_normal = ExtResource("1_hsyko")
|
||||
ignore_texture_size = true
|
||||
stretch_mode = 0
|
||||
script = ExtResource("2_4covg")
|
||||
front_texture = ExtResource("1_hsyko")
|
||||
back_texture = ExtResource("3_4covg")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="button_down" from="." to="." method="_on_button_down"]
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"]
|
24
scenes/find_a_couple/tile_grid.tscn
Normal file
24
scenes/find_a_couple/tile_grid.tscn
Normal file
|
@ -0,0 +1,24 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://exbrdfhk0bou"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://lu353vx1qhnw" path="res://scenes/find_a_couple/tile_btn.tscn" id="1_l5jho"]
|
||||
|
||||
[node name="GridContainer" type="GridContainer"]
|
||||
theme_override_constants/h_separation = 50
|
||||
theme_override_constants/v_separation = 50
|
||||
columns = 2
|
||||
|
||||
[node name="TextureButton" parent="." instance=ExtResource("1_l5jho")]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureButton2" parent="." instance=ExtResource("1_l5jho")]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureButton3" parent="." instance=ExtResource("1_l5jho")]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureButton4" parent="." instance=ExtResource("1_l5jho")]
|
||||
custom_minimum_size = Vector2(100, 100)
|
||||
layout_mode = 2
|
|
@ -1,25 +1,23 @@
|
|||
extends Area2D
|
||||
|
||||
signal tile_clicked(tile)
|
||||
extends TextureButton
|
||||
|
||||
@export var front_texture: Texture2D # Изображение на лицевой стороне
|
||||
@export var back_texture: Texture2D # Изображение на обратной стороне
|
||||
@export var flip_duration: float = 0.3 # Длительность анимации переворота
|
||||
|
||||
@onready var sprite = $Sprite2D
|
||||
@onready var timer = $Timer
|
||||
|
||||
var is_flipped: bool = false
|
||||
var can_click: bool = true
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
sprite.texture = back_texture
|
||||
texture_normal = back_texture
|
||||
|
||||
func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
|
||||
|
||||
func _on_button_down() -> void:
|
||||
if not can_click: return
|
||||
if event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT:
|
||||
emit_signal ("tile_clicked", self)
|
||||
flip_tile()
|
||||
emit_signal ("tile_clicked", self)
|
||||
flip_tile()
|
||||
|
||||
func flip_tile():
|
||||
is_flipped = true
|
||||
|
@ -33,7 +31,7 @@ func flip_tile():
|
|||
timer.start()
|
||||
|
||||
func _change_texture():
|
||||
sprite.texture = front_texture if is_flipped else back_texture
|
||||
texture_normal = front_texture if is_flipped else back_texture
|
||||
|
||||
func hide_tile():
|
||||
is_flipped = false
|
1
scripts/find_a_couple/tile.gd.uid
Normal file
1
scripts/find_a_couple/tile.gd.uid
Normal file
|
@ -0,0 +1 @@
|
|||
uid://dj8d1k52lircu
|
Loading…
Add table
Add a link
Reference in a new issue