Fixes on Receiver. Add landing frames.
This commit is contained in:
parent
ae24288db3
commit
471b1ee3db
|
|
@ -121,7 +121,7 @@ animations = [ {
|
||||||
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 14 ), SubResource( 15 ), SubResource( 15 ), SubResource( 16 ), SubResource( 16 ), SubResource( 17 ), SubResource( 17 ) ],
|
"frames": [ SubResource( 13 ), SubResource( 14 ), SubResource( 14 ), SubResource( 15 ), SubResource( 15 ), SubResource( 16 ), SubResource( 16 ), SubResource( 17 ), SubResource( 17 ) ],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": "land",
|
"name": "land",
|
||||||
"speed": 13.0
|
"speed": 16.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ],
|
"frames": [ SubResource( 19 ), SubResource( 20 ), SubResource( 21 ), SubResource( 22 ), SubResource( 23 ), SubResource( 24 ), SubResource( 25 ), SubResource( 26 ) ],
|
||||||
"loop": true,
|
"loop": true,
|
||||||
|
|
|
||||||
|
|
@ -54,10 +54,10 @@ func _process(delta):
|
||||||
# Not sure what should be called first here.
|
# Not sure what should be called first here.
|
||||||
if has_method('_state_process_' + current_state.name):
|
if has_method('_state_process_' + current_state.name):
|
||||||
call('_state_process_' + current_state.name)
|
call('_state_process_' + current_state.name)
|
||||||
process_animations()
|
#TODO: Not sure I want to do modifiers this way anymore
|
||||||
|
#process_state_modifier()
|
||||||
|
|
||||||
func _on_animation_finished():
|
func _on_animation_finished():
|
||||||
#Disabling for now:
|
|
||||||
if frames.get_animation_loop(animation) == false:
|
if frames.get_animation_loop(animation) == false:
|
||||||
#print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index)
|
#print("Stop!!!!!", current_state.animation_sequence.size(), " - ", current_state.animation_index)
|
||||||
if current_state.animation_sequence.size() > 0:
|
if current_state.animation_sequence.size() > 0:
|
||||||
|
|
@ -66,6 +66,7 @@ func _on_animation_finished():
|
||||||
if animation_index >= current_state.animation_sequence.size():
|
if animation_index >= current_state.animation_sequence.size():
|
||||||
#print("Stop!!!!!")
|
#print("Stop!!!!!")
|
||||||
current_state.animation_finished = true
|
current_state.animation_finished = true
|
||||||
|
# TODO: Allow a way to stop animation even if in a looped sequence
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
#func _process(delta):
|
#func _process(delta):
|
||||||
|
|
@ -73,7 +74,7 @@ func _on_animation_finished():
|
||||||
# If called, this will attempt to make the most appropriate animation change
|
# If called, this will attempt to make the most appropriate animation change
|
||||||
# would likely be triggered from an animation sequence finishing or a
|
# would likely be triggered from an animation sequence finishing or a
|
||||||
# modifier being applied/removed outside of enter/exit transitions.
|
# modifier being applied/removed outside of enter/exit transitions.
|
||||||
func update_animation(enter_frame := 0, index := 0, suffix := ''):
|
func change_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
## TODO:
|
## TODO:
|
||||||
# Need to find a way to attempt to keep and transfer the Index or frame
|
# Need to find a way to attempt to keep and transfer the Index or frame
|
||||||
#
|
#
|
||||||
|
|
@ -149,7 +150,7 @@ func update_animation(enter_frame := 0, index := 0, suffix := ''):
|
||||||
print("Error! Resolved to empty animation sequence!?")
|
print("Error! Resolved to empty animation sequence!?")
|
||||||
return
|
return
|
||||||
|
|
||||||
func process_animations():
|
func process_state_modifier():
|
||||||
var modifier :StateModifier = current_state.modifier
|
var modifier :StateModifier = current_state.modifier
|
||||||
if modifier != null:
|
if modifier != null:
|
||||||
if modifier.state_timeout and modifier.state_timeout.time_left == 0:
|
if modifier.state_timeout and modifier.state_timeout.time_left == 0:
|
||||||
|
|
@ -160,13 +161,13 @@ func process_animations():
|
||||||
modifier.TYPE.ANIMATION_SUFFIX:
|
modifier.TYPE.ANIMATION_SUFFIX:
|
||||||
# Attempt to seemlessly transition animations.
|
# Attempt to seemlessly transition animations.
|
||||||
modifier = null
|
modifier = null
|
||||||
update_animation(frame,animation_index)
|
change_animation(frame,animation_index)
|
||||||
|
|
||||||
modifier.TYPE.REPLACE_ANIMATION:
|
modifier.TYPE.REPLACE_ANIMATION:
|
||||||
if current_state.debug_state:
|
if current_state.debug_state:
|
||||||
print("I don't have anything for replacements yet.")
|
print("I don't have anything for replacements yet.")
|
||||||
modifier = null
|
modifier = null
|
||||||
update_animation()
|
change_animation()
|
||||||
_:
|
_:
|
||||||
modifier = null
|
modifier = null
|
||||||
return
|
return
|
||||||
|
|
@ -222,7 +223,9 @@ func _on_state_change(old_state_name:String, new_state :State):
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
update_animation()
|
change_animation()
|
||||||
|
if has_method('_on_state_change_' + current_state.name):
|
||||||
|
call('_on_state_change_' + current_state.name)
|
||||||
print("It's an animated Actor state!")
|
print("It's an animated Actor state!")
|
||||||
else:
|
else:
|
||||||
push_warning("Received non animated Actor state.")
|
push_warning("Received non animated Actor state.")
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ export var callable_state_machine :NodePath
|
||||||
var request_state_change: FuncRef
|
var request_state_change: FuncRef
|
||||||
|
|
||||||
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
||||||
var current_movement_state: String
|
|
||||||
|
|
||||||
# Since animactor state machine can actually view properties from this type
|
# Since animactor state machine can actually view properties from this type
|
||||||
# I'm thinking about moving the velocity tracker in here instead of player.
|
# I'm thinking about moving the velocity tracker in here instead of player.
|
||||||
|
|
@ -120,6 +119,8 @@ func _on_state_change(old_state_name:String, new_state :State):
|
||||||
###### State machine
|
###### State machine
|
||||||
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
if new_state is StateAnimatedActor: #Testing this. Update: It works
|
||||||
current_state = new_state
|
current_state = new_state
|
||||||
|
if has_method('_on_state_change_' + current_state.name):
|
||||||
|
call('_on_state_change_' + current_state.name)
|
||||||
else:
|
else:
|
||||||
push_warning("Received non animated Actor state.")
|
push_warning("Received non animated Actor state.")
|
||||||
#current_state = new_state
|
#current_state = new_state
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
2d/default_gravity=200
|
2d/default_gravity=280
|
||||||
common/physics_interpolation=true
|
common/physics_interpolation=true
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,10 @@ extends AnimatedSprite_StateReceiver
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
# Lets see if this nutty thing works
|
# Lets see if this nutty thing works
|
||||||
var state_ref :State
|
#var state_ref :State
|
||||||
# state_ref = get_node(callable_state_machine).get_state_reference('idle')
|
#state_ref = get_node(callable_state_machine).get_state_reference('fall')
|
||||||
# state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
#state_ref.connect("state_entered", self, "_on_state_entered_fall")
|
||||||
|
pass
|
||||||
state_ref = get_node(callable_state_machine).get_state_reference('fall')
|
|
||||||
state_ref.connect("state_entered", self, "_on_state_entered_fall")
|
|
||||||
# It works but node order really mattered.
|
|
||||||
# State machine needed to be processed first probably for ready function.
|
|
||||||
# good to know!
|
|
||||||
|
|
||||||
# I don't need this right now but I proved it can be done!
|
# I don't need this right now but I proved it can be done!
|
||||||
#func _state_process_idle():
|
#func _state_process_idle():
|
||||||
|
|
@ -22,7 +17,20 @@ func _ready():
|
||||||
#func _on_state_entered_idle():
|
#func _on_state_entered_idle():
|
||||||
# print("Anim Knows Idle State Entered!")
|
# print("Anim Knows Idle State Entered!")
|
||||||
|
|
||||||
func _on_state_entered_fall():
|
## Processing order is interesting here.
|
||||||
print ("2? got the state change signal ", current_state.name)
|
#Got call to enter state fall
|
||||||
|
#2? got the state change signal jump
|
||||||
|
#1? got the state change signal fall
|
||||||
|
#It's an animated Actor state!
|
||||||
|
## State signal comes before state machine. I'm not sure that's
|
||||||
|
## Good. Maybe I shouldn't subscribe to signals emitted by the state.
|
||||||
|
|
||||||
|
|
||||||
|
#func _on_state_entered_fall():
|
||||||
|
# print ("State Enter Signal ", current_state.name)
|
||||||
|
# frame = 2
|
||||||
|
# stop()
|
||||||
|
|
||||||
|
func _on_state_change_fall():
|
||||||
frame = 2
|
frame = 2
|
||||||
stop()
|
stop()
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,14 @@ func _state_process_physics_idle():
|
||||||
#return fall_state
|
#return fall_state
|
||||||
request_state_change.call_func('fall')
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
|
func _state_process_physics_land():
|
||||||
|
if current_state.animation_finished == true:
|
||||||
|
request_state_change.call_func('idle')
|
||||||
|
|
||||||
|
if !parent.is_on_floor():
|
||||||
|
#return fall_state
|
||||||
|
request_state_change.call_func('fall')
|
||||||
|
|
||||||
func _state_process_physics_fall():
|
func _state_process_physics_fall():
|
||||||
if desired_movement_vector.x != 0.0:
|
if desired_movement_vector.x != 0.0:
|
||||||
parent.transform.x.x = desired_movement_vector.x
|
parent.transform.x.x = desired_movement_vector.x
|
||||||
|
|
@ -69,7 +77,7 @@ func _state_process_physics_fall():
|
||||||
if parent.is_on_floor():
|
if parent.is_on_floor():
|
||||||
#modifier.reference()
|
#modifier.reference()
|
||||||
#idle_state.modifier = landing_modifier
|
#idle_state.modifier = landing_modifier
|
||||||
request_state_change.call_func('idle')
|
request_state_change.call_func('land')
|
||||||
|
|
||||||
func _state_process_physics_jump():
|
func _state_process_physics_jump():
|
||||||
if desired_movement_vector.x != 0.0:
|
if desired_movement_vector.x != 0.0:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=12 format=2]
|
[gd_scene load_steps=13 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/templates/Actor/ActorTemplate.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
[ext_resource path="res://assets/actors/players/playerE/PlayerE_SpriteFrames.tres" type="SpriteFrames" id=2]
|
||||||
|
|
@ -23,6 +23,20 @@ move_modifier_move_acceleration = 0.0
|
||||||
jerk_factor = 0.0
|
jerk_factor = 0.0
|
||||||
animation_sequence = [ "run" ]
|
animation_sequence = [ "run" ]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id=4]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
resource_name = "land"
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "land"
|
||||||
|
move_speed = 30.0
|
||||||
|
move_acceleration = 0.0
|
||||||
|
move_speed_modifier = 0.0
|
||||||
|
move_modifier_move_acceleration = 0.0
|
||||||
|
jerk_factor = 0.0
|
||||||
|
animation_sequence = [ "land" ]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 7, 14 )
|
extents = Vector2( 7, 14 )
|
||||||
|
|
||||||
|
|
@ -32,7 +46,7 @@ actor_type = "Player"
|
||||||
|
|
||||||
[node name="Movement_StateMachine" parent="." index="0"]
|
[node name="Movement_StateMachine" parent="." index="0"]
|
||||||
starting_state_name = "idle"
|
starting_state_name = "idle"
|
||||||
states = [ ExtResource( 4 ), ExtResource( 9 ), SubResource( 3 ), ExtResource( 8 ) ]
|
states = [ ExtResource( 4 ), ExtResource( 9 ), SubResource( 3 ), ExtResource( 8 ), SubResource( 4 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user