Hitboxes/Hurtboxes update

This commit is contained in:
Alan Youngblood
2024-11-10 10:04:50 -05:00
parent 3e9f095d44
commit 7cb72e12cc
17 changed files with 297 additions and 12 deletions

View File

@ -0,0 +1,18 @@
extends Node2D
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func create_grass_effect():
var GrassEffect = load("res://Effects/GrassEffect.tscn")
var grassEffect = GrassEffect.instance()
var world = get_tree().current_scene
world.add_child(grassEffect)
grassEffect.global_position = global_position
func _on_Hurtbox_area_entered(area):
create_grass_effect()
queue_free()

View File

@ -0,0 +1,27 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://World/Grass.png" type="Texture" id=1]
[ext_resource path="res://World/Grass.gd" type="Script" id=2]
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 7, 7 )
[node name="Grass" type="Node2D"]
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."]
texture = ExtResource( 1 )
centered = false
offset = Vector2( -8, -8 )
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 8, 8 )
shape = SubResource( 1 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]