gd: added input addon
This commit is contained in:
16
guide_examples/touch/background.gd
Normal file
16
guide_examples/touch/background.gd
Normal file
@ -0,0 +1,16 @@
|
||||
## This just keeps the sprite endlessly scrolling. It's not related to input.
|
||||
extends Sprite2D
|
||||
|
||||
|
||||
func _process(delta):
|
||||
# get rect of visible screen in world coordinates
|
||||
var rect = get_viewport().canvas_transform.affine_inverse() * get_viewport_rect()
|
||||
# fit the bg into the viewport
|
||||
global_position = rect.position
|
||||
global_scale = rect.size / texture.get_size()
|
||||
|
||||
# update scaling so the texture scales according to zoom level
|
||||
material.set_shader_parameter("scale", global_scale)
|
||||
var offset = rect.position / texture.get_size()
|
||||
# and offset so we pick a texture offset relative to the movement of the camera
|
||||
material.set_shader_parameter("offset", offset)
|
1
guide_examples/touch/background.gd.uid
Normal file
1
guide_examples/touch/background.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://o678yabwitsl
|
152
guide_examples/touch/background.svg
Normal file
152
guide_examples/touch/background.svg
Normal file
@ -0,0 +1,152 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg width="100%" height="100%" viewBox="0 0 1920 1080" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
||||
<g id="Artboard1" transform="matrix(2,0,0,2,0,0)">
|
||||
<rect x="0" y="0" width="960" height="540" style="fill:none;"/>
|
||||
<clipPath id="_clip1">
|
||||
<rect x="0" y="0" width="960" height="540"/>
|
||||
</clipPath>
|
||||
<g clip-path="url(#_clip1)">
|
||||
<g transform="matrix(0.5,0,0,0.5,0,0)">
|
||||
<g transform="matrix(1.24475,0,0,1.22232,-85.7788,-39.8309)">
|
||||
<rect x="68.912" y="32.586" width="772.042" height="442.599" style="fill:rgb(66,149,83);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.450896,0.307823,-0.310709,0.455124,525.083,-29.4334)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.269415,-0.157432,0.152505,0.260984,106.986,316.214)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.0120215,-0.172085,0.170625,-0.0173948,219.075,186.348)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.223981,-0.0825499,0.0885638,-0.234189,824.016,489.914)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<circle cx="159.543" cy="182.302" r="44.437" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="481.074" cy="118.528" r="19.337" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="113.93" cy="425.717" r="24.606" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="485.55" cy="307.062" r="23.813" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="840.878" cy="69.973" r="18.766" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="398.893" cy="491.121" r="20.232" style="fill:rgb(100,193,119);"/>
|
||||
<g transform="matrix(0.748773,0.662827,-0.662827,0.748773,10.3634,-112.115)">
|
||||
<rect x="122.626" y="41.18" width="53.714" height="53.714" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.965926,0.258819,-0.258819,0.965926,76.6984,-89.1342)">
|
||||
<rect x="340.345" y="210.199" width="73.05" height="73.05" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.347316,-0.451926,0.451926,0.347316,228.194,578.083)">
|
||||
<rect x="599.871" y="384.678" width="106.442" height="106.442" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.707107,0.707107,-0.707107,0.707107,376.86,-525.589)">
|
||||
<rect x="780.796" y="150.04" width="84.151" height="84.151" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.5,0,0,0.5,480,0)">
|
||||
<g transform="matrix(1.24475,0,0,1.22232,-85.7788,-39.8309)">
|
||||
<rect x="68.912" y="32.586" width="772.042" height="442.599" style="fill:rgb(66,149,83);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.450896,0.307823,-0.310709,0.455124,525.083,-29.4334)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.269415,-0.157432,0.152505,0.260984,106.986,316.214)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.0120215,-0.172085,0.170625,-0.0173948,219.075,186.348)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.223981,-0.0825499,0.0885638,-0.234189,824.016,489.914)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<circle cx="159.543" cy="182.302" r="44.437" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="481.074" cy="118.528" r="19.337" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="113.93" cy="425.717" r="24.606" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="485.55" cy="307.062" r="23.813" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="840.878" cy="69.973" r="18.766" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="398.893" cy="491.121" r="20.232" style="fill:rgb(100,193,119);"/>
|
||||
<g transform="matrix(0.748773,0.662827,-0.662827,0.748773,10.3634,-112.115)">
|
||||
<rect x="122.626" y="41.18" width="53.714" height="53.714" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.965926,0.258819,-0.258819,0.965926,76.6984,-89.1342)">
|
||||
<rect x="340.345" y="210.199" width="73.05" height="73.05" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.347316,-0.451926,0.451926,0.347316,228.194,578.083)">
|
||||
<rect x="599.871" y="384.678" width="106.442" height="106.442" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.707107,0.707107,-0.707107,0.707107,376.86,-525.589)">
|
||||
<rect x="780.796" y="150.04" width="84.151" height="84.151" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.5,0,0,0.5,0,270)">
|
||||
<g transform="matrix(1.24475,0,0,1.22232,-85.7788,-39.8309)">
|
||||
<rect x="68.912" y="32.586" width="772.042" height="442.599" style="fill:rgb(66,149,83);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.450896,0.307823,-0.310709,0.455124,525.083,-29.4334)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.269415,-0.157432,0.152505,0.260984,106.986,316.214)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.0120215,-0.172085,0.170625,-0.0173948,219.075,186.348)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.223981,-0.0825499,0.0885638,-0.234189,824.016,489.914)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<circle cx="159.543" cy="182.302" r="44.437" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="481.074" cy="118.528" r="19.337" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="113.93" cy="425.717" r="24.606" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="485.55" cy="307.062" r="23.813" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="840.878" cy="69.973" r="18.766" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="398.893" cy="491.121" r="20.232" style="fill:rgb(100,193,119);"/>
|
||||
<g transform="matrix(0.748773,0.662827,-0.662827,0.748773,10.3634,-112.115)">
|
||||
<rect x="122.626" y="41.18" width="53.714" height="53.714" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.965926,0.258819,-0.258819,0.965926,76.6984,-89.1342)">
|
||||
<rect x="340.345" y="210.199" width="73.05" height="73.05" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.347316,-0.451926,0.451926,0.347316,228.194,578.083)">
|
||||
<rect x="599.871" y="384.678" width="106.442" height="106.442" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.707107,0.707107,-0.707107,0.707107,376.86,-525.589)">
|
||||
<rect x="780.796" y="150.04" width="84.151" height="84.151" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
</g>
|
||||
<g transform="matrix(0.5,0,0,0.5,480,270)">
|
||||
<g transform="matrix(1.24475,0,0,1.22232,-85.7788,-39.8309)">
|
||||
<rect x="68.912" y="32.586" width="772.042" height="442.599" style="fill:rgb(66,149,83);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.450896,0.307823,-0.310709,0.455124,525.083,-29.4334)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.269415,-0.157432,0.152505,0.260984,106.986,316.214)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.0120215,-0.172085,0.170625,-0.0173948,219.075,186.348)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(-0.223981,-0.0825499,0.0885638,-0.234189,824.016,489.914)">
|
||||
<path d="M293.435,136.432L433.806,365.61L153.064,365.61L293.435,136.432Z" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<circle cx="159.543" cy="182.302" r="44.437" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="481.074" cy="118.528" r="19.337" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="113.93" cy="425.717" r="24.606" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="485.55" cy="307.062" r="23.813" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="840.878" cy="69.973" r="18.766" style="fill:rgb(100,193,119);"/>
|
||||
<circle cx="398.893" cy="491.121" r="20.232" style="fill:rgb(100,193,119);"/>
|
||||
<g transform="matrix(0.748773,0.662827,-0.662827,0.748773,10.3634,-112.115)">
|
||||
<rect x="122.626" y="41.18" width="53.714" height="53.714" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.965926,0.258819,-0.258819,0.965926,76.6984,-89.1342)">
|
||||
<rect x="340.345" y="210.199" width="73.05" height="73.05" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.347316,-0.451926,0.451926,0.347316,228.194,578.083)">
|
||||
<rect x="599.871" y="384.678" width="106.442" height="106.442" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
<g transform="matrix(0.707107,0.707107,-0.707107,0.707107,376.86,-525.589)">
|
||||
<rect x="780.796" y="150.04" width="84.151" height="84.151" style="fill:rgb(100,193,119);"/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 11 KiB |
37
guide_examples/touch/background.svg.import
Normal file
37
guide_examples/touch/background.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://jveia1jgm1x5"
|
||||
path="res://.godot/imported/background.svg-fba6babf7434090927a142c997b03f8a.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://guide_examples/touch/background.svg"
|
||||
dest_files=["res://.godot/imported/background.svg-fba6babf7434090927a142c997b03f8a.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
svg/scale=1.0
|
||||
editor/scale_with_editor_scale=false
|
||||
editor/convert_colors_with_editor_theme=false
|
42
guide_examples/touch/camera_2d.gd
Normal file
42
guide_examples/touch/camera_2d.gd
Normal file
@ -0,0 +1,42 @@
|
||||
## Camera control. We listen to GUIDE's actions to move and zoom the camera. Note how we can
|
||||
## mix event-based and polling based input handling, depending on what works better for the
|
||||
## use case.
|
||||
extends Camera2D
|
||||
|
||||
|
||||
@export var camera_movement:GUIDEAction
|
||||
@export var camera_zoom:GUIDEAction
|
||||
@export var camera_rotation:GUIDEAction
|
||||
@export var camera_reset:GUIDEAction
|
||||
|
||||
|
||||
@onready var _reference_zoom:Vector2 = zoom
|
||||
@onready var _reference_rotation:float = rotation
|
||||
|
||||
func _ready():
|
||||
camera_zoom.triggered.connect(_zoom_camera)
|
||||
camera_rotation.triggered.connect(_rotate_camera)
|
||||
camera_reset.triggered.connect(_reset_camera)
|
||||
# whenever zooming completes, we store the new reference zoom
|
||||
camera_zoom.completed.connect(func(): _reference_zoom = zoom)
|
||||
# whenever rotation completes, we store the new reference rotation
|
||||
camera_rotation.completed.connect(func(): _reference_rotation = rotation)
|
||||
|
||||
|
||||
|
||||
func _process(delta):
|
||||
position += camera_movement.value_axis_2d
|
||||
|
||||
|
||||
func _zoom_camera():
|
||||
zoom = clamp( _reference_zoom * camera_zoom.value_axis_1d, Vector2(0.1, 0.1), Vector2(3, 3))
|
||||
|
||||
func _rotate_camera():
|
||||
rotation = fmod(_reference_rotation + camera_rotation.value_axis_1d, TAU)
|
||||
|
||||
|
||||
func _reset_camera():
|
||||
zoom = Vector2.ONE
|
||||
rotation = 0
|
||||
_reference_zoom = zoom
|
||||
_reference_rotation = rotation
|
1
guide_examples/touch/camera_2d.gd.uid
Normal file
1
guide_examples/touch/camera_2d.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bcr7lx14f4a7o
|
15
guide_examples/touch/godot_head.gd
Normal file
15
guide_examples/touch/godot_head.gd
Normal file
@ -0,0 +1,15 @@
|
||||
extends Node2D
|
||||
|
||||
@export var lifetime_seconds:float = 5.0
|
||||
var _remaining_time_seconds:float = 0
|
||||
|
||||
func _ready():
|
||||
_remaining_time_seconds = lifetime_seconds
|
||||
|
||||
func _process(delta:float) -> void:
|
||||
_remaining_time_seconds -= delta
|
||||
if _remaining_time_seconds <= 0:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
modulate.a = _remaining_time_seconds / lifetime_seconds
|
1
guide_examples/touch/godot_head.gd.uid
Normal file
1
guide_examples/touch/godot_head.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cpb72t1olm3ug
|
10
guide_examples/touch/godot_head.tscn
Normal file
10
guide_examples/touch/godot_head.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c3kfkmt7p66c2"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/godot_head.gd" id="1_1ibdt"]
|
||||
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="2_8cdku"]
|
||||
|
||||
[node name="GodotHead" type="Node2D"]
|
||||
script = ExtResource("1_1ibdt")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_8cdku")
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://brsk1axa7e3h"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_j5nuk"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_j5nuk")
|
||||
name = &""
|
||||
action_value_type = 2
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://dhtj0p55ylhcu"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_x2v6j"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_x2v6j")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://dpu1f4xeigqdr"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_a2xs0"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_a2xs0")
|
||||
name = &""
|
||||
action_value_type = 0
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://b2xbr2rqob6gw"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_s4uaa"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_s4uaa")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
block_lower_priority_actions = true
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
13
guide_examples/touch/mapping_contexts/actions/spawn.tres
Normal file
13
guide_examples/touch/mapping_contexts/actions/spawn.tres
Normal file
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://iilpc2tjr5mx"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_4jgns"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_4jgns")
|
||||
name = &""
|
||||
action_value_type = 2
|
||||
block_lower_priority_actions = false
|
||||
emit_as_godot_actions = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
@ -0,0 +1,8 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEModifierScale" load_steps=2 format=3 uid="uid://x0g11r4xtmcv"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_scale.gd" id="1_42gxx"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_42gxx")
|
||||
scale = Vector3(0.1, 1, 1)
|
||||
apply_delta_time = false
|
157
guide_examples/touch/mapping_contexts/touch.tres
Normal file
157
guide_examples/touch/mapping_contexts/touch.tres
Normal file
@ -0,0 +1,157 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=41 format=3 uid="uid://bcepjnqawyxeb"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_touch_position.gd" id="2_r7fg4"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_canvas_coordinates.gd" id="3_br0pk"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="4_ni8em"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="5_jvujq"]
|
||||
[ext_resource type="Resource" uid="uid://brsk1axa7e3h" path="res://guide_examples/touch/mapping_contexts/actions/camera_movement.tres" id="6_5nijj"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_touch_axis_2d.gd" id="7_1c4fi"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="8_kce4k"]
|
||||
[ext_resource type="Resource" uid="uid://b2xbr2rqob6gw" path="res://guide_examples/touch/mapping_contexts/actions/camera_zoom.tres" id="10_s0k2q"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_touch_distance.gd" id="10_xxwru"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_down.gd" id="11_q5ylu"]
|
||||
[ext_resource type="Resource" uid="uid://iilpc2tjr5mx" path="res://guide_examples/touch/mapping_contexts/actions/spawn.tres" id="13_6meol"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_stability.gd" id="14_iw0b0"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="15_1y05x"]
|
||||
[ext_resource type="Resource" uid="uid://dpu1f4xeigqdr" path="res://guide_examples/touch/mapping_contexts/actions/camera_rotation.tres" id="15_2s3pg"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_hold.gd" id="15_qneu5"]
|
||||
[ext_resource type="Resource" uid="uid://dhtj0p55ylhcu" path="res://guide_examples/touch/mapping_contexts/actions/camera_reset.tres" id="16_r67n2"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_touch_angle.gd" id="16_xv1hs"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_tap.gd" id="17_h6kd2"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pajkc"]
|
||||
script = ExtResource("7_1c4fi")
|
||||
finger_count = 1
|
||||
finger_index = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_citsh"]
|
||||
script = ExtResource("8_kce4k")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ojjbt"]
|
||||
script = ExtResource("3_br0pk")
|
||||
relative_input = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_fagqu"]
|
||||
script = ExtResource("4_ni8em")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_pajkc")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_citsh"), SubResource("Resource_ojjbt")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hvdyr"]
|
||||
script = ExtResource("5_jvujq")
|
||||
action = ExtResource("6_5nijj")
|
||||
input_mappings = Array[ExtResource("4_ni8em")]([SubResource("Resource_fagqu")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6jr42"]
|
||||
script = ExtResource("10_xxwru")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_oysb7"]
|
||||
script = ExtResource("11_q5ylu")
|
||||
actuation_threshold = 0.0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_drjxq"]
|
||||
script = ExtResource("4_ni8em")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_6jr42")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_oysb7")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_otc05"]
|
||||
script = ExtResource("5_jvujq")
|
||||
action = ExtResource("10_s0k2q")
|
||||
input_mappings = Array[ExtResource("4_ni8em")]([SubResource("Resource_drjxq")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7c46x"]
|
||||
script = ExtResource("2_r7fg4")
|
||||
finger_count = 1
|
||||
finger_index = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_l3wvc"]
|
||||
script = ExtResource("3_br0pk")
|
||||
relative_input = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_o1rij"]
|
||||
script = ExtResource("14_iw0b0")
|
||||
max_deviation = 1.0
|
||||
trigger_when = 0
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_i8pe1"]
|
||||
script = ExtResource("15_qneu5")
|
||||
hold_treshold = 1.0
|
||||
is_one_shot = true
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8n6aa"]
|
||||
script = ExtResource("4_ni8em")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_7c46x")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_l3wvc")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_o1rij"), SubResource("Resource_i8pe1")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_iivaa"]
|
||||
script = ExtResource("5_jvujq")
|
||||
action = ExtResource("13_6meol")
|
||||
input_mappings = Array[ExtResource("4_ni8em")]([SubResource("Resource_8n6aa")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_p0nkc"]
|
||||
script = ExtResource("16_xv1hs")
|
||||
unit = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6twam"]
|
||||
script = ExtResource("4_ni8em")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_p0nkc")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tt5mo"]
|
||||
script = ExtResource("5_jvujq")
|
||||
action = ExtResource("15_2s3pg")
|
||||
input_mappings = Array[ExtResource("4_ni8em")]([SubResource("Resource_6twam")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4nu5w"]
|
||||
script = ExtResource("2_r7fg4")
|
||||
finger_count = 3
|
||||
finger_index = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rvgtf"]
|
||||
script = ExtResource("17_h6kd2")
|
||||
tap_threshold = 0.2
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lpakr"]
|
||||
script = ExtResource("4_ni8em")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_4nu5w")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_rvgtf")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vikxq"]
|
||||
script = ExtResource("5_jvujq")
|
||||
action = ExtResource("16_r67n2")
|
||||
input_mappings = Array[ExtResource("4_ni8em")]([SubResource("Resource_lpakr")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("15_1y05x")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("5_jvujq")]([SubResource("Resource_hvdyr"), SubResource("Resource_otc05"), SubResource("Resource_iivaa"), SubResource("Resource_tt5mo"), SubResource("Resource_vikxq")])
|
@ -0,0 +1,26 @@
|
||||
# This component shows a progress bar for the hold time, indicating to the player
|
||||
# that they must keep touching the screen until something is placed.
|
||||
extends Node2D
|
||||
|
||||
@export var spawn:GUIDEAction
|
||||
@onready var texture_progress_bar:TextureProgressBar = %TextureProgressBar
|
||||
|
||||
func _ready():
|
||||
visible = false
|
||||
# While the hold trigger is evaluating show the progress bar
|
||||
spawn.ongoing.connect(_show)
|
||||
# Once it is done, hide it again
|
||||
spawn.triggered.connect(_hide)
|
||||
# Same when it was cancelled
|
||||
spawn.cancelled.connect(_hide)
|
||||
|
||||
func _show():
|
||||
# show the indicator
|
||||
visible = true
|
||||
# move it to where we would spawn
|
||||
global_position = spawn.value_axis_2d
|
||||
# and update the progress bar
|
||||
texture_progress_bar.value = spawn.elapsed_seconds
|
||||
|
||||
func _hide():
|
||||
visible = false
|
@ -0,0 +1 @@
|
||||
uid://cnb3sumemposh
|
@ -0,0 +1,27 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c1ht6xduduxri"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/touch/placement_indicator/placement_indicator.gd" id="1_gnpc8"]
|
||||
[ext_resource type="Resource" uid="uid://iilpc2tjr5mx" path="res://guide_examples/touch/mapping_contexts/actions/spawn.tres" id="2_grp35"]
|
||||
[ext_resource type="Texture2D" uid="uid://geq3rs2fxqs4" path="res://guide_examples/touch/placement_indicator/radial_progress.png" id="2_slqs6"]
|
||||
|
||||
[node name="PlacementIndicator" type="Node2D"]
|
||||
script = ExtResource("1_gnpc8")
|
||||
spawn = ExtResource("2_grp35")
|
||||
|
||||
[node name="TextureProgressBar" type="TextureProgressBar" parent="."]
|
||||
unique_name_in_owner = true
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -96.0
|
||||
offset_top = -96.0
|
||||
offset_right = 96.0
|
||||
offset_bottom = 96.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
max_value = 1.0
|
||||
step = 0.0
|
||||
fill_mode = 4
|
||||
texture_progress = ExtResource("2_slqs6")
|
BIN
guide_examples/touch/placement_indicator/radial_progress.png
Normal file
BIN
guide_examples/touch/placement_indicator/radial_progress.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://geq3rs2fxqs4"
|
||||
path="res://.godot/imported/radial_progress.png-a1f0b05f25628c67f45ec0be27847631.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://guide_examples/touch/placement_indicator/radial_progress.png"
|
||||
dest_files=["res://.godot/imported/radial_progress.png-a1f0b05f25628c67f45ec0be27847631.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
24
guide_examples/touch/touch.gd
Normal file
24
guide_examples/touch/touch.gd
Normal file
@ -0,0 +1,24 @@
|
||||
## This example shows how to use touch gestures on mobile.
|
||||
extends Node2D
|
||||
|
||||
|
||||
@export var mapping_context:GUIDEMappingContext
|
||||
@export var spawn:GUIDEAction
|
||||
|
||||
@export var godot_head_scene:PackedScene
|
||||
|
||||
func _ready():
|
||||
GUIDE.enable_mapping_context(mapping_context)
|
||||
spawn.triggered.connect(_spawn_godot_head)
|
||||
|
||||
|
||||
func _spawn_godot_head():
|
||||
# Gets the mouse cursor from G.U.I.D.E. Note how the Canvas Coordinates
|
||||
# modifier automatically gives us touch coordinates in canvas space
|
||||
# which means we don't need to take into acount the camera panning and
|
||||
# zoom level and can just use the coordinates we get to directly place
|
||||
# a Godot head at the cursor position.
|
||||
var head = godot_head_scene.instantiate()
|
||||
add_child(head)
|
||||
|
||||
head.global_position = spawn.value_axis_2d
|
1
guide_examples/touch/touch.gd.uid
Normal file
1
guide_examples/touch/touch.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b1kmuvj74kgk8
|
88
guide_examples/touch/touch.tscn
Normal file
88
guide_examples/touch/touch.tscn
Normal file
@ -0,0 +1,88 @@
|
||||
[gd_scene load_steps=18 format=3 uid="uid://hxx7y33rfrnh"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/touch/touch.gd" id="1_gq4pr"]
|
||||
[ext_resource type="Resource" uid="uid://bcepjnqawyxeb" path="res://guide_examples/touch/mapping_contexts/touch.tres" id="2_btyg8"]
|
||||
[ext_resource type="Resource" uid="uid://iilpc2tjr5mx" path="res://guide_examples/touch/mapping_contexts/actions/spawn.tres" id="3_nwdqb"]
|
||||
[ext_resource type="Script" path="res://guide_examples/touch/camera_2d.gd" id="5_k0qyy"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kfkmt7p66c2" path="res://guide_examples/touch/godot_head.tscn" id="5_mimge"]
|
||||
[ext_resource type="Resource" uid="uid://brsk1axa7e3h" path="res://guide_examples/touch/mapping_contexts/actions/camera_movement.tres" id="7_hbc7d"]
|
||||
[ext_resource type="Resource" uid="uid://b2xbr2rqob6gw" path="res://guide_examples/touch/mapping_contexts/actions/camera_zoom.tres" id="8_t7xto"]
|
||||
[ext_resource type="Texture2D" uid="uid://slnmn5k0drdb" path="res://guide_examples/mouse_position_2d/background.svg" id="9_0mhj2"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/background.gd" id="10_7apxo"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="11_bclaf"]
|
||||
[ext_resource type="PackedScene" uid="uid://c1ht6xduduxri" path="res://guide_examples/touch/placement_indicator/placement_indicator.tscn" id="12_e3xb3"]
|
||||
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="12_fwxrg"]
|
||||
[ext_resource type="Resource" uid="uid://dpu1f4xeigqdr" path="res://guide_examples/touch/mapping_contexts/actions/camera_rotation.tres" id="13_lmkyb"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="13_n0vwi"]
|
||||
[ext_resource type="Resource" uid="uid://dhtj0p55ylhcu" path="res://guide_examples/touch/mapping_contexts/actions/camera_reset.tres" id="14_bfrfr"]
|
||||
|
||||
[sub_resource type="Shader" id="Shader_v4pj1"]
|
||||
code = "shader_type canvas_item;
|
||||
|
||||
uniform vec2 scale;
|
||||
uniform vec2 offset;
|
||||
|
||||
void vertex() {
|
||||
UV = UV * scale + offset;
|
||||
}
|
||||
|
||||
|
||||
//void light() {
|
||||
// Called for every pixel for every light affecting the CanvasItem.
|
||||
// Uncomment to replace the default light processing function with this one.
|
||||
//}
|
||||
"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_1sa2x"]
|
||||
shader = SubResource("Shader_v4pj1")
|
||||
shader_parameter/scale = Vector2(1, 1)
|
||||
shader_parameter/offset = Vector2(0, 0)
|
||||
|
||||
[node name="Touch" type="Node2D"]
|
||||
script = ExtResource("1_gq4pr")
|
||||
mapping_context = ExtResource("2_btyg8")
|
||||
spawn = ExtResource("3_nwdqb")
|
||||
godot_head_scene = ExtResource("5_mimge")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
ignore_rotation = false
|
||||
script = ExtResource("5_k0qyy")
|
||||
camera_movement = ExtResource("7_hbc7d")
|
||||
camera_zoom = ExtResource("8_t7xto")
|
||||
camera_rotation = ExtResource("13_lmkyb")
|
||||
camera_reset = ExtResource("14_bfrfr")
|
||||
|
||||
[node name="BG" type="Sprite2D" parent="."]
|
||||
texture_repeat = 2
|
||||
material = SubResource("ShaderMaterial_1sa2x")
|
||||
texture = ExtResource("9_0mhj2")
|
||||
centered = false
|
||||
script = ExtResource("10_7apxo")
|
||||
|
||||
[node name="PlacementIndicator" parent="." instance=ExtResource("12_e3xb3")]
|
||||
|
||||
[node name="UILayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="UILayer"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -107.0
|
||||
offset_top = 41.0
|
||||
offset_right = -67.0
|
||||
offset_bottom = 81.0
|
||||
grow_horizontal = 0
|
||||
theme = ExtResource("11_bclaf")
|
||||
script = ExtResource("12_fwxrg")
|
||||
instructions_text = "%s to move the camera.
|
||||
%s to zoom the camera.
|
||||
%s to rotate the camera.
|
||||
%s to reset the camera zoom and rotation.
|
||||
%s to place a Godot head.
|
||||
"
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("7_hbc7d"), ExtResource("8_t7xto"), ExtResource("13_lmkyb"), ExtResource("14_bfrfr"), ExtResource("3_nwdqb")])
|
||||
|
||||
[node name="DebuggerLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="DebuggerLayer" instance=ExtResource("13_n0vwi")]
|
||||
theme = ExtResource("11_bclaf")
|
Reference in New Issue
Block a user