Compare commits
3 Commits
d7cb6fa877
...
ae9256f083
| Author | SHA1 | Date | |
|---|---|---|---|
| ae9256f083 | |||
| c2ad46f5ae | |||
| c577a74061 |
|
|
@ -19,3 +19,4 @@ position = Vector2( 208, 20 )
|
|||
shape = SubResource( 1 )
|
||||
|
||||
[node name="PlayerE" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 112, 56 )
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ onready var sound_effect_player: AudioStreamPlayer = $SE_Player
|
|||
onready var movement_component: Movement_StateReceiver = $Movement_StateReceiver
|
||||
|
||||
#onready var movement_state_machine: StateMachineAnimatedActor = $movement_state_machine
|
||||
onready var movement_state_machine: StateMachine = $movement_state_machine
|
||||
onready var movement_state_machine: StateMachine = $Movement_StateMachine
|
||||
|
||||
var sound_effects_dict: Dictionary
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ func _ready():
|
|||
request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state')
|
||||
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
||||
self.connect("animation_finished",self,"_on_animation_finished")
|
||||
|
||||
#set current state since State machine might have set state before this
|
||||
# processed
|
||||
current_state = get_node(callable_state_machine).current_state
|
||||
|
||||
# Sprites should only have a process function
|
||||
# but if I have this will the sprite still animate?
|
||||
|
|
@ -43,6 +47,10 @@ func _process(delta):
|
|||
print("You're out of time! I saw it!")
|
||||
request_state_change.call_func('idle')
|
||||
#play()
|
||||
else:
|
||||
print("what, no current_state?")
|
||||
if has_method('_state_process_' + current_state.name):
|
||||
call('_state_process_' + current_state.name)
|
||||
process_animations()
|
||||
|
||||
func _on_animation_finished():
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ export var callable_state_machine :NodePath
|
|||
var request_state_change: FuncRef
|
||||
|
||||
onready var desired_movement_vector: Vector2 = Vector2(0,0)
|
||||
var current_movement_state:String
|
||||
var current_movement_state: String
|
||||
|
||||
# Since animactor state machine can actually view properties from this type
|
||||
# I'm thinking about moving the velocity tracker in here instead of player.
|
||||
|
|
@ -43,19 +43,23 @@ const RIGHT = 1.0
|
|||
func _ready():
|
||||
request_state_change = funcref(get_node(callable_state_machine), 'change_to_known_state')
|
||||
get_node(callable_state_machine).connect("state_changed", self,"_on_state_change")
|
||||
current_state = get_node(callable_state_machine).current_state
|
||||
|
||||
############
|
||||
# These get called by the parent
|
||||
############
|
||||
func process_physics(delta):
|
||||
move_actor_as_desired(delta)
|
||||
|
||||
if has_method('_state_process_physics_' + current_state.name):
|
||||
call('_state_process_physics_' + current_state.name)
|
||||
|
||||
# Shouldn't need a proces function
|
||||
#func process(delta):
|
||||
# pass
|
||||
|
||||
func process_input(event: InputEvent):
|
||||
pass
|
||||
if has_method('_state_process_input_' + current_state.name):
|
||||
call('_state_process_input_' + current_state.name)
|
||||
|
||||
############
|
||||
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ func change_to_known_state(new_state_name: String) -> void:
|
|||
change_state(states_index["default"])
|
||||
|
||||
func get_state_reference(state_name: String) -> State:
|
||||
print ("what you want? ", state_name)
|
||||
if states_index.has(state_name):
|
||||
return states_index[state_name]
|
||||
return null
|
||||
|
|
|
|||
|
|
@ -1,29 +1,19 @@
|
|||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://lib/classes/animated_sprite_state_receiver.gd" type="Script" id=1]
|
||||
[ext_resource path="res://lib/classes/state_machine.gd" type="Script" id=2]
|
||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=4]
|
||||
[ext_resource path="res://lib/classes/movement_state_receiver.gd" type="Script" id=5]
|
||||
[ext_resource path="res://lib/classes/actor.gd" type="Script" id=8]
|
||||
|
||||
[sub_resource type="Resource" id=1]
|
||||
script = ExtResource( 4 )
|
||||
debug_state = false
|
||||
timeout_seconds = 2.0
|
||||
name = "idle"
|
||||
move_speed = 60.0
|
||||
move_acceleration = 0.0
|
||||
move_speed_modifier = 0.0
|
||||
move_modifier_move_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "idle", "Max Height" ]
|
||||
emitter_frame_subscriptions = {
|
||||
}
|
||||
|
||||
[node name="ActorTemplate" type="KinematicBody2D"]
|
||||
collision_layer = 2
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="Movement_StateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="AnimatedSprite_StateReceiver" type="AnimatedSprite" parent="."]
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
|
|
@ -37,14 +27,10 @@ __meta__ = {
|
|||
"source": ""
|
||||
}
|
||||
}
|
||||
callable_state_machine = NodePath("../Movement_StateMachine")
|
||||
|
||||
[node name="Movement_StateReceiver" type="Node" parent="."]
|
||||
script = ExtResource( 5 )
|
||||
callable_state_machine = NodePath("../Movement_StateMachine")
|
||||
|
||||
[node name="Movement_StateMachine" type="Node" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
starting_state_name = "idle"
|
||||
states = [ SubResource( 1 ) ]
|
||||
|
||||
[node name="SE_Player" type="AudioStreamPlayer" parent="."]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
extends AnimatedSprite_StateReceiver
|
||||
|
||||
func _ready():
|
||||
# Lets see if this nutty thing works
|
||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||
# 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!
|
||||
#func _state_process_idle():
|
||||
# print("I got called!")
|
||||
|
||||
func _on_state_entered_idle():
|
||||
print("Anim Knows Idle State Entered!")
|
||||
22
src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd
Normal file
22
src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends Movement_StateReceiver
|
||||
|
||||
func _ready():
|
||||
# Lets see if this nutty thing works
|
||||
var state_ref :State = get_node(callable_state_machine).get_state_reference('idle')
|
||||
state_ref.connect("state_entered", self, "_on_state_entered_idle")
|
||||
# It works but node order really mattered.
|
||||
# State machine needed to be processed first probably for ready function.
|
||||
# good to know!
|
||||
|
||||
var fire_a_note:bool = false
|
||||
# I don't need this right now but I proved it can be done!
|
||||
func _state_process_physics_idle():
|
||||
if fire_a_note == true:
|
||||
print("I got called! (MC)")
|
||||
fire_a_note = false
|
||||
|
||||
func _on_state_entered_idle():
|
||||
print("Movement State Idle State Entered!")
|
||||
fire_a_note = true
|
||||
|
||||
|
||||
16
src/actors/players/playerE/PlayerE.gd
Normal file
16
src/actors/players/playerE/PlayerE.gd
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
extends Actor
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
|
@ -1,13 +1,26 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[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://src/actors/players/playerE/PlayerE.gd" type="Script" id=3]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/idle.tres" type="Resource" id=4]
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-AnimatedSprite_StateReceiver.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE-Movement_StateReceiver.gd" type="Script" id=6]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 7, 14 )
|
||||
|
||||
[node name="PlayerE" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 3 )
|
||||
actor_type = "Player"
|
||||
|
||||
[node name="AnimatedSprite_StateReceiver" parent="." index="0"]
|
||||
[node name="Movement_StateMachine" parent="." index="0"]
|
||||
starting_state_name = "idle"
|
||||
states = [ ExtResource( 4 ) ]
|
||||
|
||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||
frames = ExtResource( 2 )
|
||||
script = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_aseprite_wizard_config_": {
|
||||
"layer": "",
|
||||
|
|
@ -21,3 +34,10 @@ __meta__ = {
|
|||
"source": "/home/relay01/Assets/Library/Asset Packs 1-5/Asset Packs 1-4 (final)/Asset Pack-V1/Player Run/player run 48x48.aseprite"
|
||||
}
|
||||
}
|
||||
|
||||
[node name="Movement_StateReceiver" parent="." index="2"]
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." index="4"]
|
||||
position = Vector2( 0, 2 )
|
||||
shape = SubResource( 1 )
|
||||
|
|
|
|||
18
src/actors/players/playerE/states/idle.tres
Normal file
18
src/actors/players/playerE/states/idle.tres
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "idle"
|
||||
script = ExtResource( 1 )
|
||||
debug_state = false
|
||||
timeout_seconds = 2.0
|
||||
name = "idle"
|
||||
move_speed = 60.0
|
||||
move_acceleration = 0.0
|
||||
move_speed_modifier = 0.0
|
||||
move_modifier_move_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "idle" ]
|
||||
emitter_frame_subscriptions = {
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user