Refactor the animated effect to its own scene
This commit is contained in:
parent
95e301e24a
commit
a704b2939b
|
@ -1,4 +1,4 @@
|
|||
extends AnimationSprite
|
||||
extends AnimatedSprite
|
||||
|
||||
func _ready():
|
||||
self.connect("animation_finished", self, "_on_animation_finished")
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
extends Node2D
|
||||
|
||||
|
||||
onready var animated_sprite = $AnimatedSprite
|
||||
|
||||
|
||||
func _ready():
|
||||
animated_sprite.frame = 0
|
||||
animated_sprite.play("animate")
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
queue_free()
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://Effects/GrassEffect.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Effects/GrassEffect.gd" type="Script" id=2]
|
||||
[ext_resource path="res://Effects/Effects.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="AtlasTexture" id=1]
|
||||
atlas = ExtResource( 1 )
|
||||
|
@ -27,17 +27,10 @@ region = Rect2( 128, 0, 32, 32 )
|
|||
animations = [ {
|
||||
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
|
||||
"loop": false,
|
||||
"name": "animate",
|
||||
"name": "default",
|
||||
"speed": 15.0
|
||||
} ]
|
||||
|
||||
[node name="GrassEffect" type="Node2D"]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
[node name="GrassEffect" type="AnimatedSprite"]
|
||||
frames = SubResource( 6 )
|
||||
animation = "animate"
|
||||
frame = 4
|
||||
centered = false
|
||||
offset = Vector2( -8, -8 )
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
||||
script = ExtResource( 2 )
|
|
@ -2,7 +2,7 @@ extends Node2D
|
|||
|
||||
|
||||
func destroy_effect():
|
||||
var GrassEffect = load("res://World/GrassEffect.tscn")
|
||||
var GrassEffect = load("res://Effects/GrassEffect.tscn")
|
||||
var grass_effect = GrassEffect.instance()
|
||||
var world_node = get_tree().current_scene
|
||||
|
||||
|
|
Loading…
Reference in New Issue