mirror of
https://github.com/Steffo99/swear-jar.git
synced 2024-11-21 23:34:18 +00:00
Configure spawners
This commit is contained in:
parent
5b5e606f0f
commit
f844cd02d2
4 changed files with 22 additions and 20 deletions
|
@ -5,7 +5,7 @@
|
|||
[ext_resource type="Texture2D" uid="uid://2vtvoj6ua3cb" path="res://entity/coin_copper_outline_2.png" id="2_2ifq3"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6byl"]
|
||||
size = Vector2(14, 3)
|
||||
size = Vector2(16, 5)
|
||||
|
||||
[node name="CoinCopper" type="RigidBody2D"]
|
||||
collision_layer = 5
|
||||
|
|
20
root.tscn
20
root.tscn
|
@ -1,10 +1,9 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cbccs6kwwf265"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://cbccs6kwwf265"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bllsprv8orpn4" path="res://bottle/bottle.tscn" id="1_4fmd3"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kitncwpi42j" path="res://entity/coin_copper.tscn" id="2_dv01l"]
|
||||
[ext_resource type="PackedScene" uid="uid://d05b8jy3xmpcb" path="res://bottle/gravity_from_gyro.tscn" id="2_m7p4p"]
|
||||
[ext_resource type="PackedScene" uid="uid://c67lfbk4gf1ga" path="res://spawner/spawner.tscn" id="3_pubxn"]
|
||||
[ext_resource type="PackedScene" path="res://convertitore.tscn" id="5_6hpcd"]
|
||||
|
||||
[node name="Root" type="Node"]
|
||||
|
||||
|
@ -79,21 +78,18 @@ texture_filter = 1
|
|||
|
||||
[node name="GravityFromGyro" parent="UI/GameContainer/Game/Bottle" instance=ExtResource("2_m7p4p")]
|
||||
|
||||
[node name="Spawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(-24, -407)
|
||||
[node name="TimeSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(-24, -490)
|
||||
scene = ExtResource("2_dv01l")
|
||||
target_parent = NodePath("..")
|
||||
|
||||
[node name="Timer2" type="Timer" parent="UI/GameContainer/Game/Spawner"]
|
||||
[node name="Timer" type="Timer" parent="UI/GameContainer/Game/TimeSpawner"]
|
||||
autostart = true
|
||||
|
||||
[node name="TouchSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(23, -424)
|
||||
[node name="ButtonSpawner" parent="UI/GameContainer/Game" instance=ExtResource("3_pubxn")]
|
||||
position = Vector2(24, -490)
|
||||
scene = ExtResource("2_dv01l")
|
||||
target_parent = NodePath("..")
|
||||
|
||||
[node name="Convertitore" parent="UI/GameContainer/Game" instance=ExtResource("5_6hpcd")]
|
||||
position = Vector2(-110, -257)
|
||||
|
||||
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/TouchSpawner" method="spawn"]
|
||||
[connection signal="timeout" from="UI/GameContainer/Game/Spawner/Timer2" to="UI/GameContainer/Game/Spawner" method="spawn"]
|
||||
[connection signal="pressed" from="UI/Rows/UpperButtons/SpawnButton" to="UI/GameContainer/Game/ButtonSpawner" method="spawn"]
|
||||
[connection signal="timeout" from="UI/GameContainer/Game/TimeSpawner/Timer" to="UI/GameContainer/Game/TimeSpawner" method="spawn"]
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
extends Node2D
|
||||
class_name Spawner
|
||||
|
||||
|
||||
@export var scene: PackedScene
|
||||
@export var target_parent: NodePath
|
||||
|
||||
|
||||
func spawn():
|
||||
if len($Area.get_overlapping_bodies()) > 0:
|
||||
return
|
||||
var scene_instant = scene.instantiate()
|
||||
scene_instant.position=Vector2.ZERO
|
||||
add_child(scene_instant)
|
||||
var overlapping_bodies = $Area.get_overlapping_bodies()
|
||||
for overlapping_body in overlapping_bodies:
|
||||
if overlapping_body.collision_layer && 0b100:
|
||||
print("[Spawner] Not spawning, overlapping with: ", overlapping_body)
|
||||
return
|
||||
|
||||
var scene_instant = scene.instantiate()
|
||||
scene_instant.position = Vector2.ZERO
|
||||
print("[Spawner] Created: ", scene_instant)
|
||||
add_child(scene_instant)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[ext_resource type="Script" path="res://spawner/spawner.gd" id="1_xqfmg"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_p13i4"]
|
||||
size = Vector2(16, 5)
|
||||
size = Vector2(14, 3)
|
||||
|
||||
[node name="Spawner" type="Node2D"]
|
||||
script = ExtResource("1_xqfmg")
|
||||
|
|
Loading…
Reference in a new issue