Anims and states for level transitions.
This commit is contained in:
parent
8f1ebe6e09
commit
bd991d7939
14
Main.tscn
14
Main.tscn
|
|
@ -1,11 +1,14 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://src/ui/HUD.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://src/ui/scene_transition.tscn" type="PackedScene" id=4]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
|
||||
[node name="SceneTransition" parent="." instance=ExtResource( 4 )]
|
||||
|
||||
[node name="TestBox" parent="." instance=ExtResource( 2 )]
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
|
|
@ -15,12 +18,3 @@ __meta__ = {
|
|||
position = Vector2( 112, 56 )
|
||||
|
||||
[node name="UI_Layer" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
[node name="TransitionScene" type="ColorRect" parent="."]
|
||||
visible = false
|
||||
modulate = Color( 0, 0, 0, 0 )
|
||||
margin_right = 320.0
|
||||
margin_bottom = 180.0
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
|
|
|||
BIN
assets/UI/transition_screen.png
Normal file
BIN
assets/UI/transition_screen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
35
assets/UI/transition_screen.png.import
Normal file
35
assets/UI/transition_screen.png.import
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/transition_screen.png-06f8967c3d511a265f6dd663ec4973a5.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/UI/transition_screen.png"
|
||||
dest_files=[ "res://.import/transition_screen.png-06f8967c3d511a265f6dd663ec4973a5.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=false
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
|
|
@ -8,15 +8,22 @@ var player_start_position: Position2D
|
|||
|
||||
func change_level(_level_name :String):
|
||||
print("res://src/levels/" + _level_name + ".tscn" )
|
||||
var SceneTransition = get_node("/root/Main/SceneTransition")
|
||||
#var simultaneous_scene = preload("res://levels/level2.tscn").instance()
|
||||
var new_level = load("res://src/levels/" + _level_name + ".tscn" ).instance()
|
||||
#print (get_tree().get_root().get_children())
|
||||
for l in get_node("/root/Main").get_children():
|
||||
#print (get_node("/root/Main").get_children())
|
||||
if l is Level:
|
||||
SceneTransition.transition_dissolve("foo")
|
||||
yield(SceneTransition,"done")
|
||||
print(l)
|
||||
get_node("/root/Main").remove_child(l)
|
||||
get_node("/root/Main").add_child(new_level)
|
||||
get_node("/root/Main").move_child(new_level,1)
|
||||
print (get_node("/root/Main").get_children())
|
||||
SceneTransition.reset()
|
||||
#get_node("/root/Main").add_child_below_node(SceneTransition,new_level)
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
class_name LevelTransition
|
||||
extends Interactable
|
||||
|
||||
## Things like 'door_right', 'stairs'
|
||||
## helps the Player object pick an appropriate animation
|
||||
export var _transition_type := 'door_right'
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
|
|
|
|||
|
|
@ -159,6 +159,26 @@ func _state_process_physics_roll():
|
|||
#return fall_state
|
||||
request_state_change.call_func('fall')
|
||||
|
||||
var level_transition_latch: bool
|
||||
func _on_state_change_enter_right():
|
||||
#desired_movement_vector.x = RIGHT
|
||||
parent.transform.x.x = RIGHT
|
||||
level_transition_latch = false
|
||||
|
||||
func _state_process_physics_enter_right():
|
||||
#flip_sprite_to_movement_direction()
|
||||
|
||||
if current_state.state_timeout.time_left == 0 and level_transition_latch == false:
|
||||
#desired_movement_vector.x = LEFT
|
||||
parent.transform.x.x = LEFT
|
||||
current_state.state_timeout.start()
|
||||
level_transition_latch = true
|
||||
elif current_state.state_timeout.time_left == 0 and level_transition_latch == true:
|
||||
request_state_change.call_func('idle')
|
||||
|
||||
# Force role in facing direction
|
||||
# instead of movement direction
|
||||
move_actor_as_desired(parent.transform.x.x)
|
||||
|
||||
func _state_process_physics_land():
|
||||
$"../LedgeDetector".set_enabled(true)
|
||||
|
|
|
|||
|
|
@ -32,5 +32,7 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
|||
the_thing.trigger_interaction()
|
||||
return false
|
||||
if the_thing is LevelTransition:
|
||||
if the_thing._transition_type == 'door_right':
|
||||
movement_state_machine.change_to_known_state('enter_right')
|
||||
the_thing.trigger_interaction()
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=25 format=2]
|
||||
[gd_scene load_steps=26 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]
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
[ext_resource path="res://src/actors/players/playerE/states/ledge_grab.tres" type="Resource" id=19]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/ledge_climb.tres" type="Resource" id=20]
|
||||
[ext_resource path="res://lib/templates/Interactable/Interactable_Receiver.gd" type="Script" id=21]
|
||||
[ext_resource path="res://src/actors/players/playerE/states/enter_right.tres" type="Resource" id=22]
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
resource_local_to_scene = true
|
||||
|
|
@ -47,9 +48,8 @@ script = ExtResource( 3 )
|
|||
actor_type = "Player"
|
||||
|
||||
[node name="Movement_StateMachine" parent="." index="0"]
|
||||
debug_state_machine = true
|
||||
starting_state_name = "idle"
|
||||
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), ExtResource( 19 ), ExtResource( 20 ) ]
|
||||
states = [ ExtResource( 4 ), ExtResource( 9 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 12 ), ExtResource( 11 ), ExtResource( 10 ), ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), SubResource( 3 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 22 ) ]
|
||||
|
||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||
frames = ExtResource( 2 )
|
||||
|
|
|
|||
16
src/actors/players/playerE/states/enter_right.tres
Normal file
16
src/actors/players/playerE/states/enter_right.tres
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[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_local_to_scene = true
|
||||
script = ExtResource( 1 )
|
||||
debug_state = false
|
||||
timeout_seconds = 1.5
|
||||
name = "enter_right"
|
||||
horizontal_speed = 30.0
|
||||
horizontal_acceleration = 0.0
|
||||
horizontal_speed_offset = 0.0
|
||||
horizontal_speed_offset_acceleration = 0.0
|
||||
jerk_factor = 0.0
|
||||
animation_sequence = [ "walk" ]
|
||||
|
|
@ -15,7 +15,7 @@ extents = Vector2( 4.5, 10 )
|
|||
|
||||
[node name="TileMap Collision" parent="." index="1"]
|
||||
tile_set = ExtResource( 2 )
|
||||
tile_data = PoolIntArray( 0, 4, 65536, 19, 4, 65536, 65536, 4, 65536, 65555, 4, 65536, 131072, 4, 65536, 131091, 4, 65536, 196608, 4, 65536, 196620, 2, 0, 196621, 2, 1, 196622, 2, 2, 196627, 4, 65536, 262144, 4, 0, 262156, 2, 65536, 262157, 2, 65537, 262158, 2, 65538, 262163, 4, 0, 327680, 4, 65536, 327699, 4, 65536, 393216, 4, 65536, 458752, 4, 65536, 589823, 0, 1, 524288, 4, 131072, 524289, 0, 3, 524290, 0, 1, 524291, 0, 2, 524292, 0, 3, 524293, 0, 1, 524294, 0, 2, 524295, 0, 3, 524296, 0, 1, 524297, 0, 2, 524298, 0, 3, 524299, 0, 1, 524300, 0, 2, 524301, 0, 3, 524302, 0, 1, 524303, 0, 2, 524304, 0, 3, 524305, 0, 1, 524306, 0, 2, 524308, 0, 1, 524309, 0, 2, 524310, 0, 3, 655359, 0, 65537, 589824, 0, 65538, 589825, 0, 65539, 589826, 0, 65537, 589827, 0, 65538, 589828, 0, 65539, 589829, 0, 65537, 589830, 0, 65538, 589831, 0, 65539, 589832, 0, 65537, 589833, 0, 65538, 589834, 0, 65539, 589835, 0, 65537, 589836, 0, 65538, 589837, 0, 65539, 589838, 0, 65537, 589839, 0, 65538, 589840, 0, 65539, 589841, 0, 65537, 589842, 0, 65538, 589843, 0, 65539, 589844, 0, 65537, 589845, 0, 65538, 589846, 0, 65539, 720895, 0, 131073, 655360, 0, 131074, 655361, 0, 131075, 655362, 0, 131073, 655363, 0, 131074, 655364, 0, 131075, 655365, 0, 131073, 655366, 0, 131074, 655367, 0, 131075, 655368, 0, 131073, 655369, 0, 131074, 655370, 0, 131075, 655371, 0, 131073, 655372, 0, 131074, 655373, 0, 131075, 655374, 0, 131073, 655375, 0, 131074, 655376, 0, 131075, 655377, 0, 131073, 655378, 0, 131074, 655379, 0, 131075, 655380, 0, 131073, 655381, 0, 131074, 655382, 0, 131075, 786431, 0, 196609, 720896, 0, 196610, 720897, 0, 196611, 720898, 0, 196609, 720899, 0, 196610, 720900, 0, 196611, 720901, 0, 196609, 720902, 0, 196610, 720903, 0, 196611, 720904, 0, 196609, 720905, 0, 196610, 720906, 0, 196611, 720907, 0, 196609, 720908, 0, 196610, 720909, 0, 196611, 720910, 0, 196609, 720911, 0, 196610, 720912, 0, 196611, 720913, 0, 196609, 720914, 0, 196610, 720915, 0, 196611, 720916, 0, 196609, 720917, 0, 196610, 720918, 0, 196611, 851967, 0, 262145, 786432, 0, 262146, 786433, 0, 262147, 786434, 0, 262145, 786435, 0, 262146, 786436, 0, 262147, 786437, 0, 262145, 786438, 0, 262146, 786439, 0, 262147, 786440, 0, 262145, 786441, 0, 262146, 786442, 0, 262147, 786443, 0, 262145, 786444, 0, 262146, 786445, 0, 262147, 786446, 0, 262145, 786447, 0, 262146, 786448, 0, 262147, 786449, 0, 262145, 786450, 0, 262146, 786451, 0, 262147, 786452, 0, 262145, 786453, 0, 262146, 786454, 0, 262147 )
|
||||
tile_data = PoolIntArray( 0, 4, 65536, 19, 4, 65536, 65536, 4, 65536, 65555, 4, 65536, 131072, 4, 65536, 131091, 4, 65536, 196608, 4, 65536, 196620, 2, 0, 196621, 2, 1, 196622, 2, 2, 196627, 4, 65536, 262144, 4, 0, 262156, 2, 65536, 262157, 2, 65537, 262158, 2, 65538, 262163, 4, 0, 327680, 4, 65536, 327699, 4, 65536, 393216, 4, 65536, 393237, 4, 0, 458752, 4, 65536, 458773, 4, 0, 589823, 0, 1, 524288, 4, 131072, 524289, 0, 3, 524290, 0, 1, 524291, 0, 2, 524292, 0, 3, 524293, 0, 1, 524294, 0, 2, 524295, 0, 3, 524296, 0, 1, 524297, 0, 2, 524298, 0, 3, 524299, 0, 1, 524300, 0, 2, 524301, 0, 3, 524302, 0, 1, 524303, 0, 2, 524304, 0, 3, 524305, 0, 1, 524306, 0, 2, 524308, 0, 1, 524309, 4, 0, 524310, 0, 3, 655359, 0, 65537, 589824, 0, 65538, 589825, 0, 65539, 589826, 0, 65537, 589827, 0, 65538, 589828, 0, 65539, 589829, 0, 65537, 589830, 0, 65538, 589831, 0, 65539, 589832, 0, 65537, 589833, 0, 65538, 589834, 0, 65539, 589835, 0, 65537, 589836, 0, 65538, 589837, 0, 65539, 589838, 0, 65537, 589839, 0, 65538, 589840, 0, 65539, 589841, 0, 65537, 589842, 0, 65538, 589843, 0, 65539, 589844, 0, 65537, 589845, 0, 65538, 589846, 0, 65539, 720895, 0, 131073, 655360, 0, 131074, 655361, 0, 131075, 655362, 0, 131073, 655363, 0, 131074, 655364, 0, 131075, 655365, 0, 131073, 655366, 0, 131074, 655367, 0, 131075, 655368, 0, 131073, 655369, 0, 131074, 655370, 0, 131075, 655371, 0, 131073, 655372, 0, 131074, 655373, 0, 131075, 655374, 0, 131073, 655375, 0, 131074, 655376, 0, 131075, 655377, 0, 131073, 655378, 0, 131074, 655379, 0, 131075, 655380, 0, 131073, 655381, 0, 131074, 655382, 0, 131075, 786431, 0, 196609, 720896, 0, 196610, 720897, 0, 196611, 720898, 0, 196609, 720899, 0, 196610, 720900, 0, 196611, 720901, 0, 196609, 720902, 0, 196610, 720903, 0, 196611, 720904, 0, 196609, 720905, 0, 196610, 720906, 0, 196611, 720907, 0, 196609, 720908, 0, 196610, 720909, 0, 196611, 720910, 0, 196609, 720911, 0, 196610, 720912, 0, 196611, 720913, 0, 196609, 720914, 0, 196610, 720915, 0, 196611, 720916, 0, 196609, 720917, 0, 196610, 720918, 0, 196611, 851967, 0, 262145, 786432, 0, 262146, 786433, 0, 262147, 786434, 0, 262145, 786435, 0, 262146, 786436, 0, 262147, 786437, 0, 262145, 786438, 0, 262146, 786439, 0, 262147, 786440, 0, 262145, 786441, 0, 262146, 786442, 0, 262147, 786443, 0, 262145, 786444, 0, 262146, 786445, 0, 262147, 786446, 0, 262145, 786447, 0, 262146, 786448, 0, 262147, 786449, 0, 262145, 786450, 0, 262146, 786451, 0, 262147, 786452, 0, 262145, 786453, 0, 262146, 786454, 0, 262147 )
|
||||
|
||||
[node name="TileMap Foreground" parent="." index="2"]
|
||||
tile_set = ExtResource( 2 )
|
||||
|
|
|
|||
30
src/ui/scene_transition.gd
Normal file
30
src/ui/scene_transition.gd
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
extends CanvasLayer
|
||||
|
||||
signal done
|
||||
|
||||
#func change_scene(target: String, type: String = 'dissolve') -> void:
|
||||
# if type == 'dissolve':
|
||||
# transition_dissolve(target)
|
||||
# else:
|
||||
# transition_clouds(target)
|
||||
|
||||
var animation_name = ''
|
||||
|
||||
func reset():
|
||||
$AnimationPlayer.play_backwards(animation_name)
|
||||
|
||||
func transition_dissolve(target: String) -> void:
|
||||
animation_name = 'dissolve'
|
||||
$AnimationPlayer.play('dissolve')
|
||||
yield($AnimationPlayer,'animation_finished')
|
||||
emit_signal("done")
|
||||
#get_tree().change_scene(target)
|
||||
#$AnimationPlayer.play_backwards('dissolve')
|
||||
|
||||
func transition_clouds(target: String) -> void:
|
||||
animation_name = 'clouds_out'
|
||||
$AnimationPlayer.play('clouds_in')
|
||||
yield($AnimationPlayer,'animation_finished')
|
||||
emit_signal("done")
|
||||
#get_tree().change_scene(target)
|
||||
#$AnimationPlayer.play('clouds_out')
|
||||
100
src/ui/scene_transition.tscn
Normal file
100
src/ui/scene_transition.tscn
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
[gd_scene load_steps=7 format=2]
|
||||
|
||||
[ext_resource path="res://src/ui/scene_transition.gd" type="Script" id=1]
|
||||
[ext_resource path="res://assets/UI/transition_screen.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "RESET"
|
||||
length = 0.01
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("dissolve_rect:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ) ]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/path = NodePath("clouds:rect_position")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1.36422e-12, 180 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "clouds_in"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("clouds:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 1.36422e-12, 180 ), Vector2( 0, -40 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "clouds_out"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("clouds:rect_position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 0.5 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Vector2( 0, -40 ), Vector2( 1.36422e-12, -220 ) ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("dissolve_rect:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0, 1 ),
|
||||
"transitions": PoolRealArray( 1, 1 ),
|
||||
"update": 0,
|
||||
"values": [ Color( 1, 1, 1, 0 ), Color( 1, 1, 1, 1 ) ]
|
||||
}
|
||||
|
||||
[node name="SceneTransition" type="CanvasLayer"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="dissolve_rect" type="ColorRect" parent="."]
|
||||
modulate = Color( 1, 1, 1, 0 )
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
anims/RESET = SubResource( 1 )
|
||||
anims/clouds_in = SubResource( 2 )
|
||||
anims/clouds_out = SubResource( 3 )
|
||||
anims/dissolve = SubResource( 4 )
|
||||
|
||||
[node name="clouds" type="TextureRect" parent="."]
|
||||
margin_top = 180.0
|
||||
margin_right = 320.0
|
||||
margin_bottom = 360.0
|
||||
texture = ExtResource( 2 )
|
||||
Loading…
Reference in New Issue
Block a user