feat: add closed door node; add 2 new signals to puzzleButton node; connected signals to lockedDoor node;
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_oi8ly"]
|
[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="3_oi8ly"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="5_oi8ly"]
|
[ext_resource type="PackedScene" uid="uid://dhvuy8co661xo" path="res://Scenes/SceneEntrance/scene_entrance.tscn" id="5_oi8ly"]
|
||||||
[ext_resource type="PackedScene" uid="uid://orvnsdbeji56" path="res://Scenes/Block/block.tscn" id="6_12ovb"]
|
[ext_resource type="PackedScene" uid="uid://orvnsdbeji56" path="res://Scenes/Block/block.tscn" id="6_12ovb"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dfu6aj67vqwfn" path="res://Scenes/LockedDoor/locked_door.tscn" id="6_elpgg"]
|
||||||
|
[ext_resource type="Script" uid="uid://decx4kt8ftrb5" path="res://Scenes/LockedDoor/locked_door.gd" id="7_nr542"]
|
||||||
[ext_resource type="PackedScene" uid="uid://onpen57mc6i8" path="res://Scenes/PuzzleButton/puzzle_button.tscn" id="7_ohrk8"]
|
[ext_resource type="PackedScene" uid="uid://onpen57mc6i8" path="res://Scenes/PuzzleButton/puzzle_button.tscn" id="7_ohrk8"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_04h35"]
|
||||||
@@ -804,9 +806,16 @@ push_strength = 100
|
|||||||
[node name="Camera2D" type="Camera2D" parent="ObstacleLayer/Player" unique_id=1335060572]
|
[node name="Camera2D" type="Camera2D" parent="ObstacleLayer/Player" unique_id=1335060572]
|
||||||
zoom = Vector2(5, 5)
|
zoom = Vector2(5, 5)
|
||||||
|
|
||||||
|
[node name="LockedDoor" parent="ObstacleLayer" unique_id=964088255 instance=ExtResource("6_elpgg")]
|
||||||
|
position = Vector2(31, -32)
|
||||||
|
script = ExtResource("7_nr542")
|
||||||
|
|
||||||
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")]
|
[node name="SceneEntrance" parent="." unique_id=1734357035 instance=ExtResource("5_oi8ly")]
|
||||||
position = Vector2(136, -108)
|
position = Vector2(136, -108)
|
||||||
|
|
||||||
[node name="Block" parent="." unique_id=2096944035 instance=ExtResource("6_12ovb")]
|
[node name="Block" parent="." unique_id=2096944035 instance=ExtResource("6_12ovb")]
|
||||||
position = Vector2(0, -33)
|
position = Vector2(0, -33)
|
||||||
lock_rotation = true
|
lock_rotation = true
|
||||||
|
|
||||||
|
[connection signal="pressed" from="PuzzleButton" to="ObstacleLayer/LockedDoor" method="_on_puzzle_button_pressed"]
|
||||||
|
[connection signal="unpressed" from="PuzzleButton" to="ObstacleLayer/LockedDoor" method="_on_puzzle_button_unpressed"]
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
extends StaticBody2D
|
||||||
|
|
||||||
|
|
||||||
|
func _on_puzzle_button_pressed() -> void:
|
||||||
|
visible = false
|
||||||
|
$CollisionShape2D.set_deferred("disabled", true)
|
||||||
|
|
||||||
|
|
||||||
|
func _on_puzzle_button_unpressed() -> void:
|
||||||
|
visible = true
|
||||||
|
$CollisionShape2D.set_deferred("disabled", false)
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://decx4kt8ftrb5
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
[gd_scene format=3 uid="uid://dfu6aj67vqwfn"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c3l7w3n700qx3" path="res://Ninja Adventure - Asset Pack/Backgrounds/Tilesets/TilesetReliefDetail.png" id="1_vst31"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_chgu2"]
|
||||||
|
size = Vector2(16, 16)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_chgu2"]
|
||||||
|
atlas = ExtResource("1_vst31")
|
||||||
|
region = Rect2(32, 48, 15, 15)
|
||||||
|
|
||||||
|
[node name="LockedDoor" type="StaticBody2D" unique_id=964088255]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1293530655]
|
||||||
|
shape = SubResource("RectangleShape2D_chgu2")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1495827892]
|
||||||
|
texture = SubResource("AtlasTexture_chgu2")
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
extends Area2D
|
extends Area2D
|
||||||
var bodies_on_top = 0
|
var bodies_on_top = 0
|
||||||
|
signal pressed
|
||||||
|
signal unpressed
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pass # Replace with function body.
|
pass # Replace with function body.
|
||||||
@@ -14,11 +17,11 @@ func _on_body_entered(body: Node2D) -> void:
|
|||||||
bodies_on_top = bodies_on_top + 1
|
bodies_on_top = bodies_on_top + 1
|
||||||
if (body.is_in_group("pushable") or body is Player) and bodies_on_top == 1:
|
if (body.is_in_group("pushable") or body is Player) and bodies_on_top == 1:
|
||||||
$AnimatedSprite2D.play("pressed")
|
$AnimatedSprite2D.play("pressed")
|
||||||
print("PRESSED!")
|
pressed.emit()
|
||||||
|
|
||||||
|
|
||||||
func _on_body_exited(body: Node2D) -> void:
|
func _on_body_exited(body: Node2D) -> void:
|
||||||
bodies_on_top = bodies_on_top - 1
|
bodies_on_top = bodies_on_top - 1
|
||||||
if (body.is_in_group("pushable") or body is Player) and bodies_on_top == 0:
|
if (body.is_in_group("pushable") or body is Player) and bodies_on_top == 0:
|
||||||
$AnimatedSprite2D.play("unpressed")
|
$AnimatedSprite2D.play("unpressed")
|
||||||
print("UNPRESSED!")
|
unpressed.emit()
|
||||||
|
|||||||
Reference in New Issue
Block a user