gd: added input addon
This commit is contained in:
12
guide_examples/two_joysticks/actions/player_one_move.tres
Normal file
12
guide_examples/two_joysticks/actions/player_one_move.tres
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://d31d5dpoavou1"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_w3ruv"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_w3ruv")
|
||||
name = &"player_one_move"
|
||||
action_value_type = 2
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
12
guide_examples/two_joysticks/actions/player_two_move.tres
Normal file
12
guide_examples/two_joysticks/actions/player_two_move.tres
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://7g78pa31v44m"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_cuk0c"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_cuk0c")
|
||||
name = &"player_two_move"
|
||||
action_value_type = 2
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEModifierDeadzone" load_steps=2 format=3 uid="uid://cxd3gqa1bof30"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_deadzone.gd" id="1_ax1vk"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ax1vk")
|
||||
lower_threshold = 0.2
|
||||
upper_threshold = 1.0
|
12
guide_examples/two_joysticks/player.gd
Normal file
12
guide_examples/two_joysticks/player.gd
Normal file
@ -0,0 +1,12 @@
|
||||
## This is the player script. Note how we can use the same script for both
|
||||
## players, by just injecting different actions into them. No needs to check
|
||||
## which player input we should consume.
|
||||
extends Node2D
|
||||
|
||||
@export var speed:float = 150
|
||||
|
||||
@export var move_action:GUIDEAction
|
||||
|
||||
func _process(delta:float) -> void:
|
||||
position += move_action.value_axis_2d.normalized() * speed * delta
|
||||
|
1
guide_examples/two_joysticks/player.gd.uid
Normal file
1
guide_examples/two_joysticks/player.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c73evv6t30of
|
6
guide_examples/two_joysticks/two_joysticks.gd
Normal file
6
guide_examples/two_joysticks/two_joysticks.gd
Normal file
@ -0,0 +1,6 @@
|
||||
extends Node2D
|
||||
|
||||
@export var mapping_context:GUIDEMappingContext
|
||||
|
||||
func _ready():
|
||||
GUIDE.enable_mapping_context(mapping_context)
|
1
guide_examples/two_joysticks/two_joysticks.gd.uid
Normal file
1
guide_examples/two_joysticks/two_joysticks.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://byg4578fnips6
|
56
guide_examples/two_joysticks/two_joysticks.tres
Normal file
56
guide_examples/two_joysticks/two_joysticks.tres
Normal file
@ -0,0 +1,56 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=14 format=3 uid="uid://chr8ugns0fh70"]
|
||||
|
||||
[ext_resource type="Resource" uid="uid://d31d5dpoavou1" path="res://guide_examples/two_joysticks/actions/player_one_move.tres" id="1_d7e45"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="1_sp28b"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_joy_axis_2d.gd" id="2_exwu1"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="3_ga6gt"]
|
||||
[ext_resource type="Resource" uid="uid://cxd3gqa1bof30" path="res://guide_examples/two_joysticks/modifiers/joystick_deadzone.tres" id="3_xy1jy"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="4_mvoug"]
|
||||
[ext_resource type="Resource" uid="uid://7g78pa31v44m" path="res://guide_examples/two_joysticks/actions/player_two_move.tres" id="5_aeoun"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jkkrr"]
|
||||
script = ExtResource("2_exwu1")
|
||||
x = 0
|
||||
y = 1
|
||||
joy_index = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6efv4"]
|
||||
script = ExtResource("3_ga6gt")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_jkkrr")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([ExtResource("3_xy1jy")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kv6y3"]
|
||||
script = ExtResource("4_mvoug")
|
||||
action = ExtResource("1_d7e45")
|
||||
input_mappings = Array[ExtResource("3_ga6gt")]([SubResource("Resource_6efv4")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_660yw"]
|
||||
script = ExtResource("2_exwu1")
|
||||
x = 0
|
||||
y = 1
|
||||
joy_index = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kg721"]
|
||||
script = ExtResource("3_ga6gt")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_660yw")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([ExtResource("3_xy1jy")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6ruab"]
|
||||
script = ExtResource("4_mvoug")
|
||||
action = ExtResource("5_aeoun")
|
||||
input_mappings = Array[ExtResource("3_ga6gt")]([SubResource("Resource_kg721")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_sp28b")
|
||||
display_name = "Player Input"
|
||||
mappings = Array[ExtResource("4_mvoug")]([SubResource("Resource_kv6y3"), SubResource("Resource_6ruab")])
|
39
guide_examples/two_joysticks/two_joysticks.tscn
Normal file
39
guide_examples/two_joysticks/two_joysticks.tscn
Normal file
@ -0,0 +1,39 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://b2uycqcjf0hth"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/two_joysticks/two_joysticks.gd" id="1_1dy65"]
|
||||
[ext_resource type="Resource" uid="uid://chr8ugns0fh70" path="res://guide_examples/two_joysticks/two_joysticks.tres" id="2_3p2l3"]
|
||||
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="2_c65ah"]
|
||||
[ext_resource type="Script" path="res://guide_examples/two_joysticks/player.gd" id="3_3ycuu"]
|
||||
[ext_resource type="Resource" uid="uid://d31d5dpoavou1" path="res://guide_examples/two_joysticks/actions/player_one_move.tres" id="4_f356y"]
|
||||
[ext_resource type="Resource" uid="uid://7g78pa31v44m" path="res://guide_examples/two_joysticks/actions/player_two_move.tres" id="5_700m5"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="7_ojfv8"]
|
||||
|
||||
[node name="TwoJoysticks" type="Node2D"]
|
||||
script = ExtResource("1_1dy65")
|
||||
mapping_context = ExtResource("2_3p2l3")
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
offset_left = 1359.0
|
||||
offset_top = 13.0
|
||||
offset_right = 1909.0
|
||||
offset_bottom = 135.0
|
||||
text = "This demonstrates how to consume different actions in the same script. We have two players each one controlled by a joystick. Both players share a single script and just listen to different actions which are given as export parameters."
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Player1" type="Sprite2D" parent="."]
|
||||
position = Vector2(509, 509)
|
||||
texture = ExtResource("2_c65ah")
|
||||
script = ExtResource("3_3ycuu")
|
||||
move_action = ExtResource("4_f356y")
|
||||
|
||||
[node name="Player2" type="Sprite2D" parent="."]
|
||||
modulate = Color(1, 0.533333, 1, 1)
|
||||
position = Vector2(1315, 505)
|
||||
texture = ExtResource("2_c65ah")
|
||||
script = ExtResource("3_3ycuu")
|
||||
move_action = ExtResource("5_700m5")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="CanvasLayer" instance=ExtResource("7_ojfv8")]
|
||||
metadata/_edit_lock_ = true
|
Reference in New Issue
Block a user