-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathold_chloe_code
More file actions
45 lines (36 loc) · 1.46 KB
/
old_chloe_code
File metadata and controls
45 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
extends AnimatedSprite2D
# Visual animations
var animations = {
"idle_no_tail": "idle_no_tail",
"idle_no_claw": "idle_no_claw",
"idle_bot_claw": "idle_bot_claw",
"dash_no_claw": "dash_no_claw",
"dash_bot_claw": "dash_bot_claw",
"dash_two_claw": "dash_two_claw",
"walking_no_tail": "walking_no_tail",
"walking_no_claw": "walking_no_claw",
"walking_bot_claw": "walking_bot_claw"
}
#Access to lobster claw state
@onready var lobster_claw_state = $"..".lobster_state
@onready var old_animation = ""
@onready var current_animation = ""
func play_animation(animation_name):
if animation_name in animations:
current_animation = animation_name
animation = animations[animation_name]
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta: float) -> void:
var input_direction = Input.get_vector("Left","Right","Up","Down")
lobster_claw_state = str($"..".LOBSTER_STATES.keys()[$"..".lobster_state]).to_lower()
if Input.is_action_just_pressed("Run"):
if "dash" not in current_animation:
old_animation = current_animation
play_animation('dash_' + lobster_claw_state)
if input_direction != Vector2.ZERO and "dash" not in current_animation:
play_animation("walking_" + lobster_claw_state)
elif input_direction == Vector2.ZERO and "dash" not in current_animation:
play_animation("idle_" + lobster_claw_state)
func _on_animation_looped() -> void:
if "dash" in current_animation:
play_animation(old_animation)