aboutsummaryrefslogtreecommitdiffstats
path: root/KinematicBody2D.gd
diff options
context:
space:
mode:
authorfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 03:30:47 +0000
committerfreddie-a <57713959+freddie-a@users.noreply.github.com>2022-10-30 03:30:47 +0000
commit34b97ea823b1627eac2b91825cd1a748d87afd60 (patch)
tree6fc8a22fee383e46b56099134f1fc2844aa35b15 /KinematicBody2D.gd
parent61fe177dc7ed9f0f667fc28b85cc68ce166e3410 (diff)
Add coin scoring
Diffstat (limited to 'KinematicBody2D.gd')
-rw-r--r--KinematicBody2D.gd8
1 files changed, 6 insertions, 2 deletions
diff --git a/KinematicBody2D.gd b/KinematicBody2D.gd
index 3bbb3a9..22f7db1 100644
--- a/KinematicBody2D.gd
+++ b/KinematicBody2D.gd
@@ -1,6 +1,7 @@
extends Area2D
signal hit
+signal coin
var screen_size
export (int) var speed = 500
var spawn_object = load("res://Bullet.tscn")
@@ -31,8 +32,11 @@ func _physics_process(delta):
if Input.is_action_just_pressed("click"):
var obj = spawn_object.instance()
obj.position = get_position()
- get_owner().add_child(obj)
+ get_parent().add_child(obj)
var bodies = get_overlapping_bodies()
for body in bodies:
- if not "Bullet" in body.get_name():
+ if "Coin" in body.get_name():
+ emit_signal("coin")
+ body.free()
+ elif "Enemy" in body.get_name():
emit_signal("hit", delta)