gd: added input addon
This commit is contained in:
11
guide_examples/tap_and_hold/mapping_contexts/jump.tres
Normal file
11
guide_examples/tap_and_hold/mapping_contexts/jump.tres
Normal file
@ -0,0 +1,11 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://djow080f02fos"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_dxeu7"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_dxeu7")
|
||||
name = &""
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,9 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://dcdlaiw50k4t3"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_mgxtb"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_mgxtb")
|
||||
name = ""
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,74 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=17 format=3 uid="uid://dkorp45s6fjqk"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://djow080f02fos" path="res://guide_examples/tap_and_hold/mapping_contexts/jump.tres" id="1_pwkn3"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_key.gd" id="2_6utl5"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="3_sfabf"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_tap.gd" id="4_0qfc2"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="4_nrdxn"]
|
||||
[ext_resource type="Resource" uid="uid://dcdlaiw50k4t3" path="res://guide_examples/tap_and_hold/mapping_contexts/somersault.tres" id="6_5qh27"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_hold.gd" id="7_sj5n7"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="8_q4q7m"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_fvatf"]
|
||||
script = ExtResource("2_6utl5")
|
||||
key = 32
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_k188c"]
|
||||
script = ExtResource("4_0qfc2")
|
||||
tap_threshold = 0.2
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tg2ja"]
|
||||
script = ExtResource("3_sfabf")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_fvatf")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_k188c")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ghgfq"]
|
||||
script = ExtResource("4_nrdxn")
|
||||
action = ExtResource("1_pwkn3")
|
||||
input_mappings = Array[ExtResource("3_sfabf")]([SubResource("Resource_tg2ja")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_75xxu"]
|
||||
script = ExtResource("2_6utl5")
|
||||
key = 32
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_dum1i"]
|
||||
script = ExtResource("7_sj5n7")
|
||||
hold_treshold = 0.5
|
||||
is_one_shot = true
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tbykh"]
|
||||
script = ExtResource("3_sfabf")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_75xxu")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_dum1i")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_5u3vu"]
|
||||
script = ExtResource("4_nrdxn")
|
||||
action = ExtResource("6_5qh27")
|
||||
input_mappings = Array[ExtResource("3_sfabf")]([SubResource("Resource_tbykh")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("8_q4q7m")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("4_nrdxn")]([SubResource("Resource_ghgfq"), SubResource("Resource_5u3vu")])
|
30
guide_examples/tap_and_hold/player.gd
Normal file
30
guide_examples/tap_and_hold/player.gd
Normal file
@ -0,0 +1,30 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
@onready var _animation_player:AnimationPlayer = %AnimationPlayer
|
||||
@onready var _progress_bar:ProgressBar = %ProgressBar
|
||||
|
||||
@export var jump_action:GUIDEAction
|
||||
@export var somersault_action:GUIDEAction
|
||||
|
||||
func _ready():
|
||||
jump_action.triggered.connect(_play.bind("jump"))
|
||||
somersault_action.triggered.connect(_play.bind("somersault"))
|
||||
somersault_action.ongoing.connect(_update_progress_bar)
|
||||
somersault_action.triggered.connect(_hide_progress_bar)
|
||||
somersault_action.cancelled.connect(_hide_progress_bar)
|
||||
|
||||
func _play(animation:String):
|
||||
if _animation_player.is_playing():
|
||||
return
|
||||
|
||||
_animation_player.play(animation)
|
||||
|
||||
func _update_progress_bar():
|
||||
# exceeds tap time
|
||||
if somersault_action.elapsed_seconds > 0.1:
|
||||
_progress_bar.value = somersault_action.elapsed_ratio
|
||||
_progress_bar.visible = true
|
||||
|
||||
func _hide_progress_bar():
|
||||
_progress_bar.visible = false
|
1
guide_examples/tap_and_hold/player.gd.uid
Normal file
1
guide_examples/tap_and_hold/player.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://brd1oa6q1qsl3
|
6
guide_examples/tap_and_hold/tap_and_hold.gd
Normal file
6
guide_examples/tap_and_hold/tap_and_hold.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends Node
|
||||
|
||||
@export var mapping_context:GUIDEMappingContext
|
||||
|
||||
func _ready():
|
||||
GUIDE.enable_mapping_context(mapping_context)
|
1
guide_examples/tap_and_hold/tap_and_hold.gd.uid
Normal file
1
guide_examples/tap_and_hold/tap_and_hold.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dpkjsi6bk64ly
|
154
guide_examples/tap_and_hold/tap_and_hold.tscn
Normal file
154
guide_examples/tap_and_hold/tap_and_hold.tscn
Normal file
@ -0,0 +1,154 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://bq1y86drsbsgc"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/tap_and_hold/tap_and_hold.gd" id="1_ek3h7"]
|
||||
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="1_segxn"]
|
||||
[ext_resource type="Script" path="res://guide_examples/tap_and_hold/player.gd" id="2_gpfh8"]
|
||||
[ext_resource type="Resource" uid="uid://dkorp45s6fjqk" path="res://guide_examples/tap_and_hold/mapping_contexts/tap_and_hold.tres" id="3_u8e88"]
|
||||
[ext_resource type="Resource" uid="uid://djow080f02fos" path="res://guide_examples/tap_and_hold/mapping_contexts/jump.tres" id="4_8qeav"]
|
||||
[ext_resource type="Resource" uid="uid://dcdlaiw50k4t3" path="res://guide_examples/tap_and_hold/mapping_contexts/somersault.tres" id="5_wp1cr"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="6_r6oud"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="6_vjlt4"]
|
||||
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="7_304xo"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_j3lvc"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Player:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(546, 317)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Player:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [0.0]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_a86xu"]
|
||||
resource_name = "jump"
|
||||
length = 0.5
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Player:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(546, 317), Vector2(546, 260), Vector2(546, 317)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_fir1a"]
|
||||
resource_name = "somersault"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Player:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.5, 1),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Vector2(546, 317), Vector2(546, 200), Vector2(546, 317)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("Player:rotation")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.3, 0.5, 0.7),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [0.0, 0.0, -3.14159, -6.28319]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8sm1c"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_j3lvc"),
|
||||
"jump": SubResource("Animation_a86xu"),
|
||||
"somersault": SubResource("Animation_fir1a")
|
||||
}
|
||||
|
||||
[node name="TapAndHold" type="Node"]
|
||||
script = ExtResource("1_ek3h7")
|
||||
mapping_context = ExtResource("3_u8e88")
|
||||
|
||||
[node name="Player" type="Sprite2D" parent="."]
|
||||
position = Vector2(546, 317)
|
||||
texture = ExtResource("1_segxn")
|
||||
script = ExtResource("2_gpfh8")
|
||||
jump_action = ExtResource("4_8qeav")
|
||||
somersault_action = ExtResource("5_wp1cr")
|
||||
|
||||
[node name="ProgressBar" type="ProgressBar" parent="Player"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
offset_left = -58.0
|
||||
offset_top = 64.0
|
||||
offset_right = 57.0
|
||||
offset_bottom = 91.0
|
||||
max_value = 1.0
|
||||
show_percentage = false
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_8sm1c")
|
||||
}
|
||||
|
||||
[node name="UI Layer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="Instructions Label" type="RichTextLabel" parent="UI Layer"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -473.0
|
||||
offset_top = 527.0
|
||||
offset_right = -226.0
|
||||
offset_bottom = 550.0
|
||||
grow_horizontal = 0
|
||||
theme = ExtResource("6_r6oud")
|
||||
script = ExtResource("7_304xo")
|
||||
instructions_text = "Tap %s to jump.
|
||||
Hold %s to somersault."
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("4_8qeav"), ExtResource("5_wp1cr")])
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="Label" type="Label" parent="UI Layer"]
|
||||
visible = false
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -660.0
|
||||
offset_top = 71.0
|
||||
offset_right = -57.0
|
||||
offset_bottom = 223.0
|
||||
grow_horizontal = 0
|
||||
theme = ExtResource("6_r6oud")
|
||||
text = "This demonstrates using the hold and tap triggers to bind multiple actions to the same key. This also uses the hold action's elapsed_ratio property to drive a hold progress bar to indicate how long the key needs to be held."
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Debug Layer" type="CanvasLayer" parent="."]
|
||||
visible = false
|
||||
|
||||
[node name="GuideDebugger" parent="Debug Layer" instance=ExtResource("6_vjlt4")]
|
||||
theme = ExtResource("6_r6oud")
|
||||
metadata/_edit_lock_ = true
|
Reference in New Issue
Block a user