Add the bat's death effect
This commit is contained in:
parent
86cdaff230
commit
937578ef33
|
@ -0,0 +1,58 @@
|
||||||
|
[gd_scene load_steps=14 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Effects/EnemyDeathEffect.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://Effects/Effects.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=1]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 0, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=2]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 32, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=3]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 64, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=4]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 96, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=5]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 128, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=6]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 160, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=7]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 192, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=8]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 224, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=9]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 256, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id=10]
|
||||||
|
atlas = ExtResource( 1 )
|
||||||
|
region = Rect2( 288, 0, 32, 32 )
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id=11]
|
||||||
|
animations = [ {
|
||||||
|
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ), SubResource( 10 ) ],
|
||||||
|
"loop": false,
|
||||||
|
"name": "animate",
|
||||||
|
"speed": 15.0
|
||||||
|
} ]
|
||||||
|
|
||||||
|
[node name="EnemyDeathEffect" type="AnimatedSprite"]
|
||||||
|
frames = SubResource( 11 )
|
||||||
|
animation = "animate"
|
||||||
|
offset = Vector2( 0, -8 )
|
||||||
|
script = ExtResource( 2 )
|
|
@ -1,5 +1,7 @@
|
||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
|
const DeathEffect = preload("res://Effects/EnemyDeathEffect.tscn")
|
||||||
|
|
||||||
var knockback = Vector2.ZERO
|
var knockback = Vector2.ZERO
|
||||||
onready var stats = $Stats
|
onready var stats = $Stats
|
||||||
|
|
||||||
|
@ -14,3 +16,6 @@ func _on_HurtBox_area_entered(area):
|
||||||
|
|
||||||
func _on_Stats_no_health():
|
func _on_Stats_no_health():
|
||||||
queue_free()
|
queue_free()
|
||||||
|
var effect = DeathEffect.instance()
|
||||||
|
get_parent().add_child(effect)
|
||||||
|
effect.global_position = global_position
|
||||||
|
|
|
@ -48,7 +48,7 @@ script = ExtResource( 4 )
|
||||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||||
frames = SubResource( 6 )
|
frames = SubResource( 6 )
|
||||||
animation = "Fly"
|
animation = "Fly"
|
||||||
frame = 2
|
frame = 1
|
||||||
playing = true
|
playing = true
|
||||||
offset = Vector2( 0, -12 )
|
offset = Vector2( 0, -12 )
|
||||||
|
|
||||||
|
|
|
@ -649,7 +649,7 @@ position = Vector2( 16, 0 )
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 8
|
collision_mask = 8
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
damage = 2
|
damage = 1
|
||||||
|
|
||||||
[node name="CollisionShape2D" parent="HitBoxPosition/SwordHitBox" index="0"]
|
[node name="CollisionShape2D" parent="HitBoxPosition/SwordHitBox" index="0"]
|
||||||
shape = SubResource( 46 )
|
shape = SubResource( 46 )
|
||||||
|
|
|
@ -5,15 +5,17 @@ const GrassEffect = preload("res://Effects/GrassEffect.tscn")
|
||||||
func destroy_effect():
|
func destroy_effect():
|
||||||
|
|
||||||
var grass_effect = GrassEffect.instance()
|
var grass_effect = GrassEffect.instance()
|
||||||
var world_node = get_tree().current_scene
|
|
||||||
|
|
||||||
# We add the effect to the world and not to the grass itself since
|
# We add the effect to the parent and not to the grass itself since
|
||||||
# we're going to free the current node later.
|
# we're going to free the current node later.
|
||||||
|
|
||||||
# The better way to do it is to add the animated sprite in the same seen
|
# The better way to do it is to add the animated sprite in the same scense
|
||||||
# as the grass statically and just play the animation here and disable the it's
|
# as the grass statically and just play the animation here and disable its
|
||||||
# interaction with the world such as hurt box
|
# interaction with the world such as hurt box
|
||||||
world_node.add_child(grass_effect)
|
|
||||||
|
# The parent in this case is a YSort node which makes the effect follow the
|
||||||
|
# ysort rules
|
||||||
|
get_parent().add_child(grass_effect)
|
||||||
# set the position of the effect to the global_position of the current grass
|
# set the position of the effect to the global_position of the current grass
|
||||||
grass_effect.global_position = global_position
|
grass_effect.global_position = global_position
|
||||||
|
|
||||||
|
|
26
world.tscn
26
world.tscn
|
@ -506,11 +506,22 @@ tile_data = PoolIntArray( 196614, 0, 131077, 327679, 0, 131074, 262144, 0, 13107
|
||||||
|
|
||||||
[node name="Ground" type="YSort" parent="."]
|
[node name="Ground" type="YSort" parent="."]
|
||||||
|
|
||||||
[node name="Tree" parent="Ground" instance=ExtResource( 4 )]
|
[node name="player" parent="Ground" instance=ExtResource( 2 )]
|
||||||
position = Vector2( 248, 104 )
|
position = Vector2( 32, 88 )
|
||||||
|
|
||||||
|
[node name="Enemies" type="YSort" parent="Ground"]
|
||||||
|
|
||||||
|
[node name="Bat" parent="Ground/Enemies" instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 112, 88 )
|
||||||
|
|
||||||
|
[node name="Bat2" parent="Ground/Enemies" instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 272, 120 )
|
||||||
|
|
||||||
[node name="Bushes" type="YSort" parent="Ground"]
|
[node name="Bushes" type="YSort" parent="Ground"]
|
||||||
|
|
||||||
|
[node name="Tree" parent="Ground/Bushes" instance=ExtResource( 4 )]
|
||||||
|
position = Vector2( 248, 104 )
|
||||||
|
|
||||||
[node name="Bush" parent="Ground/Bushes" instance=ExtResource( 1 )]
|
[node name="Bush" parent="Ground/Bushes" instance=ExtResource( 1 )]
|
||||||
position = Vector2( 48, 56 )
|
position = Vector2( 48, 56 )
|
||||||
|
|
||||||
|
@ -551,14 +562,3 @@ position = Vector2( 32, 128 )
|
||||||
|
|
||||||
[node name="Grass3" parent="Ground/Grass" instance=ExtResource( 7 )]
|
[node name="Grass3" parent="Ground/Grass" instance=ExtResource( 7 )]
|
||||||
position = Vector2( 16, 144 )
|
position = Vector2( 16, 144 )
|
||||||
|
|
||||||
[node name="Enemies" type="YSort" parent="."]
|
|
||||||
|
|
||||||
[node name="player" parent="Enemies" instance=ExtResource( 2 )]
|
|
||||||
position = Vector2( 32, 88 )
|
|
||||||
|
|
||||||
[node name="Bat" parent="Enemies" instance=ExtResource( 8 )]
|
|
||||||
position = Vector2( 112, 88 )
|
|
||||||
|
|
||||||
[node name="Bat2" parent="Enemies" instance=ExtResource( 8 )]
|
|
||||||
position = Vector2( 272, 120 )
|
|
||||||
|
|
Loading…
Reference in New Issue