mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-25 17:14:20 +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
|
@export var target_parent: NodePath
|
||||||
|
|
||||||
func spawn():
|
func spawn():
|
||||||
if len($Area2D.get_overlapping_bodies()) > 0:
|
if len($Area.get_overlapping_bodies()) > 0:
|
||||||
return
|
return
|
||||||
var scene_instant = scene.instantiate()
|
var scene_instant = scene.instantiate()
|
||||||
scene_instant.position=Vector2.ZERO
|
scene_instant.position=Vector2.ZERO
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_xnebx"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"]
|
||||||
size = Vector2(100, 20)
|
size = Vector2(16, 5)
|
||||||
|
|
||||||
[node name="Spawner" type="Node2D"]
|
[node name="Spawner" type="Node2D"]
|
||||||
script = ExtResource("1_xqfmg")
|
script = ExtResource("1_xqfmg")
|
||||||
|
@ -12,11 +12,11 @@ script = ExtResource("1_xqfmg")
|
||||||
wait_time = 0.1
|
wait_time = 0.1
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Area" type="Area2D" parent="."]
|
||||||
collision_mask = 4
|
collision_mask = 4
|
||||||
|
|
||||||
[node name="Shape" type="CollisionShape2D" parent="Area2D"]
|
[node name="CoinShape" type="CollisionShape2D" parent="Area"]
|
||||||
position = Vector2(0, -15)
|
scale = Vector2(3, 3)
|
||||||
shape = SubResource("RectangleShape2D_xnebx")
|
shape = SubResource("RectangleShape2D_p13i4")
|
||||||
|
|
||||||
[connection signal="timeout" from="Timer" to="." method="spawn"]
|
[connection signal="timeout" from="Timer" to="." method="spawn"]
|
||||||
|
|
Loading…
Reference in a new issue