Demo.tscn 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [gd_scene load_steps=8 format=3 uid="uid://dmn8nkpogiwsf"]
  2. [ext_resource type="PackedScene" uid="uid://bpdyvy2681m3i" path="res://player/Player.tscn" id="1"]
  3. [ext_resource type="PackedScene" uid="uid://cvi13chv8g4hj" path="res://debug/StatesStackDiplayer.tscn" id="3"]
  4. [ext_resource type="PackedScene" uid="uid://bq6rrfy53rfvo" path="res://debug/ControlsPanel.tscn" id="4"]
  5. [sub_resource type="Animation" id="1"]
  6. [sub_resource type="Animation" id="2"]
  7. length = 0.6
  8. tracks/0/type = "value"
  9. tracks/0/imported = false
  10. tracks/0/enabled = true
  11. tracks/0/path = NodePath("BodyPivot/Body:modulate")
  12. tracks/0/interp = 1
  13. tracks/0/loop_wrap = true
  14. tracks/0/keys = {
  15. "times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.4),
  16. "transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1),
  17. "update": 0,
  18. "values": [Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1), Color(1, 0, 0, 1), Color(1, 1, 1, 1)]
  19. }
  20. [sub_resource type="Animation" id="3"]
  21. [sub_resource type="AnimationLibrary" id="AnimationLibrary_qbwwp"]
  22. _data = {
  23. "idle": SubResource("1"),
  24. "stagger": SubResource("2"),
  25. "walk": SubResource("3")
  26. }
  27. [node name="Demo" type="Node"]
  28. [node name="Player" parent="." instance=ExtResource("1")]
  29. position = Vector2(640, 400)
  30. [node name="StateMachine" parent="Player" index="0"]
  31. start_state = NodePath("Idle")
  32. [node name="AnimationPlayer" parent="Player" index="1"]
  33. libraries = {
  34. "": SubResource("AnimationLibrary_qbwwp")
  35. }
  36. [node name="Explanations" type="RichTextLabel" parent="."]
  37. anchors_preset = 15
  38. anchor_right = 1.0
  39. anchor_bottom = 1.0
  40. offset_left = 10.0
  41. offset_top = -370.0
  42. offset_right = -10.0
  43. offset_bottom = -730.0
  44. grow_horizontal = 2
  45. grow_vertical = 2
  46. size_flags_vertical = 4
  47. mouse_filter = 2
  48. bbcode_enabled = true
  49. text = "This example shows how to apply the State programming pattern in GDScript, including Hierarchical States, and a pushdown automaton.
  50. States are common in games. You can use the pattern to:
  51. 1. Separate each behavior and transitions between behaviors, thus make scripts shorter and easier to manage.
  52. 2. Respect the Single Responsibility Principle. Each State object represents one action.
  53. 3. Improve your code's structure. Look at the scene tree and FileSystem tab: without looking at the code, you'll know what the Player can or cannot do.
  54. You can read more about States in the excellent Game Programming Patterns ebook."
  55. [node name="Control" type="Control" parent="."]
  56. layout_mode = 3
  57. anchors_preset = 15
  58. anchor_right = 1.0
  59. anchor_bottom = 1.0
  60. grow_horizontal = 2
  61. grow_vertical = 2
  62. [node name="StatesStackDiplayer" parent="Control" instance=ExtResource("3")]
  63. layout_mode = 0
  64. [node name="ControlsPanel" parent="Control" instance=ExtResource("4")]
  65. layout_mode = 1
  66. [editable path="Player"]