feat: add counter of the scrolls to the player node;
This commit is contained in:
@@ -16,6 +16,7 @@ func _ready() -> void:
|
|||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
move_player()
|
move_player()
|
||||||
push_blocks()
|
push_blocks()
|
||||||
|
update_scrolls()
|
||||||
|
|
||||||
func move_player():
|
func move_player():
|
||||||
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
var move_vector: Vector2 = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
|
||||||
@@ -47,6 +48,8 @@ func push_blocks():
|
|||||||
|
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
|
func update_scrolls():
|
||||||
|
$CanvasLayer/Panel/Label.text = str(SceneManager.opened_chests.size())
|
||||||
|
|
||||||
func _on_area_2d_body_entered(body: Node2D) -> void:
|
func _on_area_2d_body_entered(body: Node2D) -> void:
|
||||||
if body.is_in_group("interactable"):
|
if body.is_in_group("interactable"):
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
|
[ext_resource type="Script" uid="uid://duilaa5lwqeup" path="res://Scenes/Player/player.gd" id="1_a3d8c"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
|
[ext_resource type="Texture2D" uid="uid://cjbvc07lh4x1b" path="res://Ninja Adventure - Asset Pack/Actor/Characters/KnightGold/SeparateAnim/Walk.png" id="2_a3d8c"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://6dmy1j0t5mqy" path="res://Ninja Adventure - Asset Pack/Items/Scroll/ScrollEmpty.png" id="3_xpcdj"]
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_a3d8c"]
|
||||||
atlas = ExtResource("2_a3d8c")
|
atlas = ExtResource("2_a3d8c")
|
||||||
@@ -145,6 +146,9 @@ height = 10.0
|
|||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_chgu2"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_chgu2"]
|
||||||
size = Vector2(8, 8)
|
size = Vector2(8, 8)
|
||||||
|
|
||||||
|
[sub_resource type="LabelSettings" id="LabelSettings_chgu2"]
|
||||||
|
font_size = 48
|
||||||
|
|
||||||
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1991398375]
|
[node name="CharacterBody2D" type="CharacterBody2D" unique_id=1991398375]
|
||||||
collision_mask = 7
|
collision_mask = 7
|
||||||
motion_mode = 1
|
motion_mode = 1
|
||||||
@@ -165,5 +169,30 @@ collision_layer = 2
|
|||||||
shape = SubResource("RectangleShape2D_chgu2")
|
shape = SubResource("RectangleShape2D_chgu2")
|
||||||
debug_color = Color(0.9427947, 0.09120729, 0.5535774, 0.41960785)
|
debug_color = Color(0.9427947, 0.09120729, 0.5535774, 0.41960785)
|
||||||
|
|
||||||
|
[node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1672000946]
|
||||||
|
|
||||||
|
[node name="Panel" type="Panel" parent="CanvasLayer" unique_id=1717998937]
|
||||||
|
offset_left = 50.0
|
||||||
|
offset_top = 52.0
|
||||||
|
offset_right = 264.0
|
||||||
|
offset_bottom = 125.0
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="CanvasLayer/Panel" unique_id=1669846200]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 78.0
|
||||||
|
offset_top = 2.0
|
||||||
|
offset_right = 118.0
|
||||||
|
offset_bottom = 69.0
|
||||||
|
text = "0"
|
||||||
|
label_settings = SubResource("LabelSettings_chgu2")
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="CanvasLayer/Panel" unique_id=1105594124]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_left = 9.0
|
||||||
|
offset_top = 8.0
|
||||||
|
offset_right = 63.0
|
||||||
|
offset_bottom = 62.0
|
||||||
|
texture = ExtResource("3_xpcdj")
|
||||||
|
|
||||||
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
|
||||||
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]
|
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]
|
||||||
|
|||||||
Reference in New Issue
Block a user