Fix Ghost's Aim Trail

main
Luna Brovchuk 2023-10-01 17:24:09 +02:00
parent 340e50d770
commit 99202166eb
4 changed files with 22 additions and 18 deletions

View File

@ -5,17 +5,27 @@
[ext_resource path="res://src/models/enemies/ghost/sprites/aiming/aiming_spriteframes.tres" type="SpriteFrames" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5.5, 5.5 )
extents = Vector2( 7, 9 )
[node name="Ghost" type="KinematicBody2D" groups=["enemy", "ghost"]]
z_index = 2
script = ExtResource( 2 )
[node name="Aim" type="AnimatedSprite" parent="."]
position = Vector2( 9, 14 )
frames = ExtResource( 3 )
animation = "idle"
frame = 7
playing = true
centered = false
offset = Vector2( -6, -6 )
flip_h = true
[node name="Sprite" type="AnimatedSprite" parent="."]
use_parent_material = true
frames = ExtResource( 1 )
animation = "idle"
frame = 1
frame = 2
playing = true
centered = false
@ -24,12 +34,3 @@ centered = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 8.5, 13.5 )
shape = SubResource( 1 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 9, 13 )
frames = ExtResource( 3 )
animation = "idle"
frame = 8
playing = true
centered = false
flip_h = true

View File

@ -11,14 +11,21 @@ func _ready():
func _physics_process(delta):
var dist = global_position.distance_to(player.global_position)
if dist > 25 and dash_target == Vector2.ZERO:
$Aim.visible = false
global_position = global_position.move_toward(player.global_position, dist * delta * speed_multiplier)
else:
if dash_target == Vector2.ZERO:
var angle = global_position.angle_to_point(player.global_position) + PI
$Aim.rotation_degrees = 0
$Aim.rotate(angle)
$Aim.visible = true
$Aim.frame = 0
$Aim.play("idle")
dash_target = global_position + Vector2(60, 0).rotated(angle)
if dash_target != Vector2.ZERO:
dash_timer += delta
if dash_timer >= 1.0:
$Aim.visible = false
dash_timer = 0
dashing = true

View File

@ -36,8 +36,8 @@ region = Rect2( 0, 77, 60, 11 )
[resource]
animations = [ {
"frames": [ null, SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ],
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ) ],
"loop": false,
"name": "idle",
"speed": 18.0
"speed": 16.0
} ]

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=2]
[gd_scene load_steps=21 format=2]
[ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1]
[ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2]
@ -16,7 +16,6 @@
[ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14]
[ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15]
[ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16]
[ext_resource path="res://src/models/enemies/rat/Rat.tscn" type="PackedScene" id=17]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 10, 60 )
@ -89,9 +88,6 @@ position = Vector2( 142, 54 )
[node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )]
position = Vector2( 509, 100 )
[node name="Rat" parent="View/Enemies" instance=ExtResource( 17 )]
position = Vector2( 93, 72 )
[node name="UIWrapper" type="CanvasLayer" parent="."]
layer = 3