Fixing Ghost Enemy
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
extends KinematicBody2D
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
onready var animation_player: AnimationPlayer = get_node("AnimationPlayer")
|
||||
onready var animated_sprite = $AnimatedSprite
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
animation_player.play("appear")
|
||||
self.visible = false
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
#animated_sprite.play("idle")
|
||||
|
||||
|
||||
func _on_Area2D_body_entered(body):
|
||||
self.visible = true
|
||||
animated_sprite.play("appear")
|
||||
|
||||
|
||||
func _on_AnimatedSprite_animation_finished():
|
||||
animated_sprite.play("idle")
|
||||
|
@@ -1,38 +1,147 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=32 format=2]
|
||||
|
||||
[ext_resource path="res://Sprites/Assets/ghost-appears.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Sprites/Assets/ghost-idle.png" type="Texture" id=2]
|
||||
[ext_resource path="res://Sprites/Assets/ghost-shriek.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Sprites/Assets/ghost-vanish.png" type="Texture" id=4]
|
||||
[ext_resource path="res://Enemies/Ghost_Enemy.gd" type="Script" id=5]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "appear"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( ),
|
||||
"transitions": PoolRealArray( ),
|
||||
"update": 1,
|
||||
"values": [ ]
|
||||
}
|
||||
[sub_resource type="AtlasTexture" id=3]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 0, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "idle"
|
||||
length = 4.0
|
||||
step = 0.6
|
||||
[sub_resource type="AtlasTexture" id=4]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 64, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="CircleShape2D" id=28]
|
||||
radius = 28.3009
|
||||
[sub_resource type="AtlasTexture" id=5]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 128, 0, 64, 80 )
|
||||
|
||||
[node name="KinematicBody2D" type="KinematicBody2D"]
|
||||
[sub_resource type="AtlasTexture" id=6]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 192, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=7]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 256, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=8]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 320, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=9]
|
||||
atlas = ExtResource( 2 )
|
||||
region = Rect2( 384, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=10]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 0, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=11]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 64, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=12]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 128, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=13]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 192, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=14]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 256, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=15]
|
||||
atlas = ExtResource( 1 )
|
||||
region = Rect2( 320, 0, 64, 48 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=16]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 0, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=17]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 64, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=18]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 128, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=19]
|
||||
atlas = ExtResource( 3 )
|
||||
region = Rect2( 192, 0, 64, 80 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=20]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 0, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=21]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 64, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=22]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 128, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=23]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 192, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=24]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 256, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=25]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 320, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="AtlasTexture" id=26]
|
||||
atlas = ExtResource( 4 )
|
||||
region = Rect2( 384, 0, 64, 64 )
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ],
|
||||
"loop": true,
|
||||
"name": "idle",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 10 ), SubResource( 11 ), SubResource( 12 ), SubResource( 13 ), SubResource( 14 ), SubResource( 15 ) ],
|
||||
"loop": true,
|
||||
"name": "appear",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 16 ), SubResource( 17 ), SubResource( 18 ), SubResource( 19 ) ],
|
||||
"loop": true,
|
||||
"name": "shriek",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ],
|
||||
"loop": true,
|
||||
"name": "vanish",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=27]
|
||||
radius = 37.8109
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
script = ExtResource( 5 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/appear = SubResource( 1 )
|
||||
anims/idle = SubResource( 3 )
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
frames = SubResource( 1 )
|
||||
animation = "appear"
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
position = Vector2( 0.209557, 1.52058 )
|
||||
collision_mask = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 28 )
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
position = Vector2( 0.187286, 0 )
|
||||
shape = SubResource( 27 )
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite" to="." method="_on_AnimatedSprite_animation_finished"]
|
||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||
|
Reference in New Issue
Block a user