mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-21 23:34:18 +00:00
Prevent spawn if coins would overlap
This commit is contained in:
parent
42c2344ec0
commit
0f51e2e8d6
2 changed files with 7 additions and 7 deletions
|
@ -4,7 +4,7 @@ class_name Spawner
|
|||
@export var target_parent: NodePath
|
||||
|
||||
func spawn():
|
||||
if len($Area2D.get_overlapping_bodies()) > 0:
|
||||
if len($Area.get_overlapping_bodies()) > 0:
|
||||
return
|
||||
var scene_instant = scene.instantiate()
|
||||
scene_instant.position=Vector2.ZERO
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xnebx"]
|
||||
size = Vector2(100, 20)
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"]
|
||||
size = Vector2(16, 5)
|
||||
|
||||
[node name="Spawner" type="Node2D"]
|
||||
script = ExtResource("1_xqfmg")
|
||||
|
@ -12,11 +12,11 @@ script = ExtResource("1_xqfmg")
|
|||
wait_time = 0.1
|
||||
autostart = true
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
[node name="Area" type="Area2D" parent="."]
|
||||
collision_mask = 4
|
||||
|
||||
[node name="Shape" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2(0, -15)
|
||||
shape = SubResource("RectangleShape2D_xnebx")
|
||||
[node name="CoinShape" type="CollisionShape2D" parent="Area"]
|
||||
scale = Vector2(3, 3)
|
||||
shape = SubResource("RectangleShape2D_p13i4")
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="spawn"]
|
||||
|
|
Loading…
Reference in a new issue