Fixing Ghost Enemy

This commit is contained in:
Jasmine Hyder
2021-12-04 19:52:58 -06:00
parent 5a3ae103f5
commit fae11f8d95
8 changed files with 274 additions and 36 deletions

View File

@@ -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")

View File

@@ -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"]

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=78 format=2]
[gd_scene load_steps=81 format=2]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://Levels/Level 2.gd" type="Script" id=2]
@@ -9,9 +9,11 @@
[ext_resource path="res://Sprites/Assets/cliffTileset.png" type="Texture" id=7]
[ext_resource path="res://GUI/HUD.tscn" type="PackedScene" id=8]
[ext_resource path="res://Enemies/Ghost_Enemy.tscn" type="PackedScene" id=9]
[ext_resource path="res://Sprites/Assets/DeadTree.png" type="Texture" id=10]
[ext_resource path="res://Sprites/Assets/darkForestTileset.png" type="Texture" id=11]
[ext_resource path="res://Levels/Area2D.gd" type="Script" id=12]
[ext_resource path="res://Levels/Camera2D.gd" type="Script" id=13]
[ext_resource path="res://Sprites/Assets/Shadow.png" type="Texture" id=14]
[sub_resource type="TileSet" id=1]
0/name = "darkForestTileset.png 0"
@@ -638,6 +640,9 @@ points = PoolVector2Array( 33.0868, 45.5302, 15.4222, 45.5302, 15.4222, 39.0812,
[sub_resource type="StreamTexture" id=62]
[sub_resource type="ConvexPolygonShape2D" id=66]
points = PoolVector2Array( 34.2487, 55.6436, 7.92332, 55.4821, 14.222, 39.5738, 27.7885, 39.7353 )
[sub_resource type="TileSet" id=63]
1/name = "Plants and Trees.png 1"
1/texture = ExtResource( 4 )
@@ -709,6 +714,41 @@ points = PoolVector2Array( 33.0868, 45.5302, 15.4222, 45.5302, 15.4222, 39.0812,
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0
6/name = "DeadTree.png 6"
6/texture = ExtResource( 10 )
6/tex_offset = Vector2( 0, 0 )
6/modulate = Color( 1, 1, 1, 1 )
6/region = Rect2( 94, 89, 39, 66 )
6/tile_mode = 0
6/occluder_offset = Vector2( 0, 0 )
6/navigation_offset = Vector2( 0, 0 )
6/shape_offset = Vector2( 0, 0 )
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
6/shape = SubResource( 66 )
6/shape_one_way = false
6/shape_one_way_margin = 1.0
6/shapes = [ {
"autotile_coord": Vector2( 0, 0 ),
"one_way": false,
"one_way_margin": 1.0,
"shape": SubResource( 66 ),
"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 )
} ]
6/z_index = 4
7/name = "Shadow.png 7"
7/texture = ExtResource( 14 )
7/tex_offset = Vector2( 0, 0 )
7/modulate = Color( 1, 1, 1, 1 )
7/region = Rect2( 97, 126, 39, 17 )
7/tile_mode = 0
7/occluder_offset = Vector2( 0, 0 )
7/navigation_offset = Vector2( 0, 0 )
7/shape_offset = Vector2( 0, 0 )
7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
7/shape_one_way = false
7/shape_one_way_margin = 0.0
7/shapes = [ ]
7/z_index = 0
[sub_resource type="RectangleShape2D" id=64]
@@ -775,9 +815,10 @@ tile_data = PoolIntArray( -851953, 0, 3, -851952, 0, 4, -786417, 0, 65538, -7864
tile_set = SubResource( 63 )
cell_size = Vector2( 16, 16 )
cell_custom_transform = Transform2D( 16, 0, 0, 16, 0, 0 )
cell_tile_origin = 1
cell_y_sort = true
format = 1
tile_data = PoolIntArray( -851962, 3, 2, -851959, 3, 131072, -786431, 3, 0, -786420, 3, 65537, -720877, 1, 0, -655358, 1, 0, -655356, 1, 0, -655354, 1, 0, -655352, 1, 0, -524290, 1, 0, -589821, 1, 0, -589818, 1, 0, -589802, 3, 65537, -524287, 3, 131072, -393217, 1, 0, -458751, 1, 0, -458730, 3, 1, -327684, 3, 2, -393216, 1, 0, -393211, 1, 0, -393199, 1, 0, -393195, 3, 65538, -262146, 3, 65537, -327677, 1, 0, -327665, 1, 0, -196611, 3, 65538, -262144, 1, 0, -262142, 1, 0, -262139, 1, 0, -262127, 1, 0, -262125, 1, 0, -196593, 3, 131072, -131057, 1, 0, -131054, 1, 0, -65527, 3, 0, -65523, 3, 65537, -65514, 3, 0, 2, 1, 0, 11, 3, 65536, 17, 1, 0, 65536, 1, 0, 65537, 3, 1, 65540, 1, 0, 65551, 1, 0, 65552, 3, 65538, 65555, 1, 0, 131074, 1, 0, 131082, 1, 0, 131089, 1, 0, 196608, 1, 0, 196614, 3, 65536, 196616, 1, 0, 196630, 3, 131072, 262147, 3, 0, 262153, 0, 4, 393214, 3, 65536, 327682, 0, 3, 327687, 0, 3, 327688, 0, 131074, 327689, 0, 65536, 327692, 3, 131073, 458751, 3, 2, 393217, 0, 3, 393218, 0, 131074, 393222, 0, 131073, 393223, 0, 131074, 393224, 0, 0, 393225, 0, 65540, 393233, 3, 131074, 393238, 3, 1, 458753, 1, 0, 458754, 0, 1, 458755, 1, 0, 458757, 1, 0, 458758, 0, 1, 458759, 0, 1, 458760, 0, 65540, 458761, 3, 2, 458773, 3, 65537, 524288, 1, 0, 524291, 0, 65539, 524292, 0, 65540, 524295, 3, 131072, 524303, 3, 2, 524305, 1, 0, 524308, 3, 2, 589828, 1, 0, 589830, 1, 0, 720894, 3, 131074, 655360, 1, 0, 655361, 3, 65536, 655368, 3, 65537, 655382, 3, 1, 786434, 3, 1, 786438, 3, 0, 786440, 3, 65536, 786443, 3, 0, 786445, 3, 65537, 786453, 3, 65538, 851974, 3, 2 )
tile_data = PoolIntArray( -2883568, 6, 0, -2818047, 6, 0, -2818023, 6, 0, -2752509, 6, 0, -2752505, 6, 0, -2752501, 6, 0, -2686971, 6, 0, -2686967, 6, 0, -2686953, 6, 0, -2686952, 6, 0, -2621440, 6, 0, -2555884, 6, 0, -2490345, 6, 0, -2359274, 3, 2, -2293753, 3, 1, -2293745, 6, 0, -2293741, 6, 0, -2162686, 6, 0, -1966061, 6, 0, -1966055, 6, 0, -1900518, 3, 2, -1834988, 6, 0, -1834986, 6, 0, -1769466, 6, 0, -1769453, 6, 0, -1769450, 6, 0, -1703932, 6, 0, -1703930, 6, 0, -1703915, 6, 0, -1703904, 1, 0, -1638400, 6, 0, -1572858, 6, 0, -1507308, 6, 0, -1441790, 6, 0, -1441788, 6, 0, -1441782, 3, 1, -1441771, 6, 0, -1376253, 6, 0, -1376233, 6, 0, -1245182, 6, 0, -1245177, 6, 0, -1179630, 6, 0, -851962, 3, 2, -851959, 3, 131072, -786431, 3, 0, -786420, 3, 65537, -720877, 1, 0, -655358, 1, 0, -655356, 1, 0, -655354, 1, 0, -655352, 1, 0, -524290, 1, 0, -589821, 1, 0, -589818, 1, 0, -589802, 3, 65537, -524287, 3, 131072, -393217, 1, 0, -458751, 1, 0, -458730, 3, 1, -327684, 3, 2, -393216, 1, 0, -393211, 1, 0, -393199, 1, 0, -393195, 3, 65538, -262146, 3, 65537, -327677, 1, 0, -327665, 1, 0, -196611, 3, 65538, -262144, 1, 0, -262142, 1, 0, -262139, 1, 0, -262127, 1, 0, -262125, 1, 0, -196593, 3, 131072, -131057, 1, 0, -131054, 1, 0, -65527, 3, 0, -65523, 3, 65537, -65514, 3, 0, 2, 1, 0, 11, 3, 65536, 17, 1, 0, 65536, 1, 0, 65537, 3, 1, 65540, 1, 0, 65551, 1, 0, 65552, 3, 65538, 65555, 1, 0, 131074, 1, 0, 131082, 1, 0, 131089, 1, 0, 196608, 1, 0, 196614, 3, 65536, 196616, 1, 0, 196630, 3, 131072, 262147, 3, 0, 262153, 0, 4, 393214, 3, 65536, 327682, 0, 3, 327687, 0, 3, 327688, 0, 131074, 327689, 0, 65536, 327692, 3, 131073, 458751, 3, 2, 393217, 0, 3, 393218, 0, 131074, 393222, 0, 131073, 393223, 0, 131074, 393224, 0, 0, 393225, 0, 65540, 393233, 3, 131074, 393238, 3, 1, 458753, 1, 0, 458754, 0, 1, 458755, 1, 0, 458757, 1, 0, 458758, 0, 1, 458759, 0, 1, 458760, 0, 65540, 458761, 3, 2, 458773, 3, 65537, 524288, 1, 0, 524291, 0, 65539, 524292, 0, 65540, 524295, 3, 131072, 524303, 3, 2, 524305, 1, 0, 524308, 3, 2, 589828, 1, 0, 589830, 1, 0, 720894, 3, 131074, 655360, 1, 0, 655361, 3, 65536, 655368, 3, 65537, 655382, 3, 1, 786434, 3, 1, 786438, 3, 0, 786440, 3, 65536, 786443, 3, 0, 786445, 3, 65537, 786453, 3, 65538, 851974, 3, 2 )
[node name="Collectible" type="Node2D" parent="."]
@@ -796,6 +837,8 @@ object_scene = ExtResource( 6 )
script = ExtResource( 12 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="TreasureChest/ChestDetection"]
position = Vector2( -1.78381, -1.18921 )
scale = Vector2( 3.08, 1.96 )
shape = SubResource( 64 )
[node name="PortalDarkForest" type="Area2D" parent="TreasureChest"]

8
Levels/Treasure Chest.gd Normal file
View File

@@ -0,0 +1,8 @@
extends AnimatedSprite
export(PackedScene) var object_scene: PackedScene = null
var is_player_inside: bool = false
var is_opened: bool = false
onready var animationplayer: AnimationPlayer = get_node("AnimationPlayer")

BIN
Sprites/Assets/DeadTree.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/DeadTree.png-29d269ef2e2b52a27cd840c6c4498c68.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Assets/DeadTree.png"
dest_files=[ "res://.import/DeadTree.png-29d269ef2e2b52a27cd840c6c4498c68.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

BIN
Sprites/Assets/Shadow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Shadow.png-cf11892f876311a2338c5880e01be385.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/Assets/Shadow.png"
dest_files=[ "res://.import/Shadow.png-cf11892f876311a2338c5880e01be385.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0