mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-13 14:02:23 +02:00
Start of animation player state mashine
This commit is contained in:
@@ -7,25 +7,3 @@ func _ready():
|
||||
"split_up": $SplitUp,
|
||||
"stagger": $Stagger
|
||||
}
|
||||
|
||||
func _change_state(state_name):
|
||||
# The base state_machine interface this node extends does most of the work
|
||||
if not _active:
|
||||
return
|
||||
if state_name in ["stagger"]:
|
||||
states_stack.push_front(states_map[state_name])
|
||||
if state_name == "jump" and current_state == $Move:
|
||||
$Jump.initialize($Move.speed, $Move.velocity)
|
||||
._change_state(state_name)
|
||||
|
||||
func _input(event):
|
||||
"""
|
||||
Here we only handle input that can interrupt states, attacking in this case
|
||||
otherwise we let the state node handle it
|
||||
"""
|
||||
if event.is_action_pressed("attack"):
|
||||
if current_state == $Attack:
|
||||
return
|
||||
_change_state("attack")
|
||||
return
|
||||
current_state.handle_input(event)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
extends "res://Boss/SlimeBoss/States/Motion/MotionState.gd"
|
||||
extends "res://Overlap/StateMachine/MotionState.gd"
|
||||
|
||||
func enter():
|
||||
owner.get_node("AnimationPlayer").play("MoveDown") # TODO: Replace animation
|
||||
@@ -9,4 +9,5 @@ func handle_input(event):
|
||||
func update(delta):
|
||||
var input_direction = get_input_direction()
|
||||
if input_direction:
|
||||
emit_signal("finished", "move")
|
||||
# emit_signal("finished", "move")
|
||||
pass
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
extends "res://Overlap/StateMachine/State.gd"
|
||||
|
||||
func get_input_direction():
|
||||
var input_direction = Vector2()
|
||||
input_direction.x = int(Input.is_action_pressed("move_right")) - int(Input.is_action_pressed("move_left"))
|
||||
input_direction.y = int(Input.is_action_pressed("move_down")) - int(Input.is_action_pressed("move_up"))
|
||||
return input_direction
|
||||
Reference in New Issue
Block a user