gd: added input addon
This commit is contained in:
16
guide_examples/mouse_position_2d/background.gd
Normal file
16
guide_examples/mouse_position_2d/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/mouse_position_2d/background.gd.uid
Normal file
1
guide_examples/mouse_position_2d/background.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://by6w26jgvaitm
|
152
guide_examples/mouse_position_2d/background.svg
Normal file
152
guide_examples/mouse_position_2d/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/mouse_position_2d/background.svg.import
Normal file
37
guide_examples/mouse_position_2d/background.svg.import
Normal file
@ -0,0 +1,37 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://slnmn5k0drdb"
|
||||
path="res://.godot/imported/background.svg-2c00776905f8df1964b7da3b2242aa3e.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://guide_examples/mouse_position_2d/background.svg"
|
||||
dest_files=["res://.godot/imported/background.svg-2c00776905f8df1964b7da3b2242aa3e.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
|
19
guide_examples/mouse_position_2d/camera_2d.gd
Normal file
19
guide_examples/mouse_position_2d/camera_2d.gd
Normal file
@ -0,0 +1,19 @@
|
||||
## 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 speed:float = 300
|
||||
|
||||
|
||||
func _ready():
|
||||
camera_zoom.triggered.connect(_zoom_camera)
|
||||
|
||||
func _process(delta):
|
||||
position += camera_movement.value_axis_2d * speed * delta
|
||||
|
||||
func _zoom_camera():
|
||||
zoom = clamp( zoom + Vector2.ONE * camera_zoom.value_axis_1d, Vector2(0.1, 0.1), Vector2(3, 3))
|
1
guide_examples/mouse_position_2d/camera_2d.gd.uid
Normal file
1
guide_examples/mouse_position_2d/camera_2d.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cndto72qu3boe
|
15
guide_examples/mouse_position_2d/godot_head.gd
Normal file
15
guide_examples/mouse_position_2d/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/mouse_position_2d/godot_head.gd.uid
Normal file
1
guide_examples/mouse_position_2d/godot_head.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://c5wpkmya4n248
|
10
guide_examples/mouse_position_2d/godot_head.tscn
Normal file
10
guide_examples/mouse_position_2d/godot_head.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cj8m2n32yjxka"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/godot_head.gd" id="1_7od3t"]
|
||||
[ext_resource type="Texture2D" uid="uid://byjxtsekdl8t2" path="res://guide_examples/shared/godot_logo.svg" id="1_1168h"]
|
||||
|
||||
[node name="GodotHead" type="Node2D"]
|
||||
script = ExtResource("1_7od3t")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_1168h")
|
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEAction" load_steps=2 format=3 uid="uid://ehdejslyo58y"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_clx3u"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_clx3u")
|
||||
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://6dm5j1sdhdp2"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_u52q5"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_u52q5")
|
||||
name = &""
|
||||
action_value_type = 1
|
||||
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://y7q516rtjlt8"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_casem"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_casem")
|
||||
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://cap7r63x8tait"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action.gd" id="1_y7wt7"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_y7wt7")
|
||||
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,8 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEModifierScale" load_steps=2 format=3 uid="uid://d0brjke26hsk8"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_scale.gd" id="1_vqbea"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_vqbea")
|
||||
scale = Vector3(0.1, 1, 1)
|
||||
apply_delta_time = false
|
@ -0,0 +1,207 @@
|
||||
[gd_resource type="Resource" script_class="GUIDEMappingContext" load_steps=43 format=3 uid="uid://cfbk5croqnocs"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_mapping_context.gd" id="1_ru5nv"]
|
||||
[ext_resource type="Resource" uid="uid://y7q516rtjlt8" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/cursor.tres" id="1_ybilq"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_mouse_position.gd" id="2_xu301"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_input_mapping.gd" id="3_vy8se"]
|
||||
[ext_resource type="Script" path="res://addons/guide/guide_action_mapping.gd" id="4_pisoh"]
|
||||
[ext_resource type="Resource" uid="uid://ehdejslyo58y" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/camera_movement.tres" id="6_qfh27"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_key.gd" id="6_u43ni"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_negate.gd" id="7_668rf"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_input_swizzle.gd" id="8_o7tqa"]
|
||||
[ext_resource type="Script" path="res://addons/guide/inputs/guide_input_mouse_button.gd" id="10_g5tce"]
|
||||
[ext_resource type="Resource" uid="uid://cap7r63x8tait" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/spawn.tres" id="10_ohwve"]
|
||||
[ext_resource type="Script" path="res://addons/guide/triggers/guide_trigger_pressed.gd" id="11_5ifuu"]
|
||||
[ext_resource type="Script" path="res://addons/guide/modifiers/guide_modifier_canvas_coordinates.gd" id="11_j8wbm"]
|
||||
[ext_resource type="Resource" uid="uid://6dm5j1sdhdp2" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/camera_zoom.tres" id="13_htiyk"]
|
||||
[ext_resource type="Resource" uid="uid://d0brjke26hsk8" path="res://guide_examples/mouse_position_2d/mapping_contexts/modifiers/zoom_sensitivity.tres" id="14_0gubt"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_420bm"]
|
||||
script = ExtResource("2_xu301")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_hqwk3"]
|
||||
script = ExtResource("11_j8wbm")
|
||||
relative_input = false
|
||||
|
||||
[sub_resource type="Resource" id="Resource_wsyf2"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_420bm")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_hqwk3")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_4f0pb"]
|
||||
script = ExtResource("4_pisoh")
|
||||
action = ExtResource("1_ybilq")
|
||||
input_mappings = Array[ExtResource("3_vy8se")]([SubResource("Resource_wsyf2")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jlr8l"]
|
||||
script = ExtResource("6_u43ni")
|
||||
key = 87
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_o78ws"]
|
||||
script = ExtResource("7_668rf")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8gssa"]
|
||||
script = ExtResource("8_o7tqa")
|
||||
order = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_qmv1n"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_jlr8l")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_o78ws"), SubResource("Resource_8gssa")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7q6a3"]
|
||||
script = ExtResource("6_u43ni")
|
||||
key = 83
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_l8svn"]
|
||||
script = ExtResource("8_o7tqa")
|
||||
order = 0
|
||||
|
||||
[sub_resource type="Resource" id="Resource_j8u0l"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_7q6a3")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_l8svn")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_asguk"]
|
||||
script = ExtResource("6_u43ni")
|
||||
key = 65
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ly8fj"]
|
||||
script = ExtResource("7_668rf")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6m3qh"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_asguk")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_ly8fj")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vbr6o"]
|
||||
script = ExtResource("6_u43ni")
|
||||
key = 68
|
||||
shift = false
|
||||
control = false
|
||||
alt = false
|
||||
meta = false
|
||||
allow_additional_modifiers = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xiclq"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_vbr6o")
|
||||
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_hvdyr"]
|
||||
script = ExtResource("4_pisoh")
|
||||
action = ExtResource("6_qfh27")
|
||||
input_mappings = Array[ExtResource("3_vy8se")]([SubResource("Resource_qmv1n"), SubResource("Resource_j8u0l"), SubResource("Resource_6m3qh"), SubResource("Resource_xiclq")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3v4no"]
|
||||
script = ExtResource("10_g5tce")
|
||||
button = 4
|
||||
|
||||
[sub_resource type="Resource" id="Resource_l152p"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_3v4no")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([ExtResource("14_0gubt")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_wlhft"]
|
||||
script = ExtResource("10_g5tce")
|
||||
button = 5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_b581m"]
|
||||
script = ExtResource("7_668rf")
|
||||
x = true
|
||||
y = true
|
||||
z = true
|
||||
|
||||
[sub_resource type="Resource" id="Resource_xrajm"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_wlhft")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([SubResource("Resource_b581m"), ExtResource("14_0gubt")])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_otc05"]
|
||||
script = ExtResource("4_pisoh")
|
||||
action = ExtResource("13_htiyk")
|
||||
input_mappings = Array[ExtResource("3_vy8se")]([SubResource("Resource_l152p"), SubResource("Resource_xrajm")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_w5sbr"]
|
||||
script = ExtResource("10_g5tce")
|
||||
button = 1
|
||||
|
||||
[sub_resource type="Resource" id="Resource_omxoi"]
|
||||
script = ExtResource("11_5ifuu")
|
||||
actuation_threshold = 0.5
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8n6aa"]
|
||||
script = ExtResource("3_vy8se")
|
||||
override_action_settings = false
|
||||
is_remappable = false
|
||||
display_name = ""
|
||||
display_category = ""
|
||||
input = SubResource("Resource_w5sbr")
|
||||
modifiers = Array[Resource("res://addons/guide/modifiers/guide_modifier.gd")]([])
|
||||
triggers = Array[Resource("res://addons/guide/triggers/guide_trigger.gd")]([SubResource("Resource_omxoi")])
|
||||
|
||||
[sub_resource type="Resource" id="Resource_iivaa"]
|
||||
script = ExtResource("4_pisoh")
|
||||
action = ExtResource("10_ohwve")
|
||||
input_mappings = Array[ExtResource("3_vy8se")]([SubResource("Resource_8n6aa")])
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1_ru5nv")
|
||||
display_name = ""
|
||||
mappings = Array[ExtResource("4_pisoh")]([SubResource("Resource_4f0pb"), SubResource("Resource_hvdyr"), SubResource("Resource_otc05"), SubResource("Resource_iivaa")])
|
26
guide_examples/mouse_position_2d/mouse_position.gd
Normal file
26
guide_examples/mouse_position_2d/mouse_position.gd
Normal file
@ -0,0 +1,26 @@
|
||||
## This example shows how to get access to the mouse cursor without being
|
||||
## specific about where the input comes from.
|
||||
extends Node2D
|
||||
|
||||
|
||||
@export var mapping_context:GUIDEMappingContext
|
||||
@export var spawn:GUIDEAction
|
||||
@export var cursor: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 mouse 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 = cursor.value_axis_2d
|
1
guide_examples/mouse_position_2d/mouse_position.gd.uid
Normal file
1
guide_examples/mouse_position_2d/mouse_position.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://cvoeomxm2dwyr
|
79
guide_examples/mouse_position_2d/mouse_position.tscn
Normal file
79
guide_examples/mouse_position_2d/mouse_position.tscn
Normal file
@ -0,0 +1,79 @@
|
||||
[gd_scene load_steps=16 format=3 uid="uid://c4de28wapdqtp"]
|
||||
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/mouse_position.gd" id="1_rkyn8"]
|
||||
[ext_resource type="Resource" uid="uid://cfbk5croqnocs" path="res://guide_examples/mouse_position_2d/mapping_contexts/mouse_position.tres" id="2_f4xly"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkr80d2pi0d41" path="res://addons/guide/debugger/guide_debugger.tscn" id="2_yylue"]
|
||||
[ext_resource type="Resource" uid="uid://y7q516rtjlt8" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/cursor.tres" id="3_e2cui"]
|
||||
[ext_resource type="Resource" uid="uid://cap7r63x8tait" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/spawn.tres" id="3_e16oi"]
|
||||
[ext_resource type="Theme" uid="uid://dot0gi1yoqmrl" path="res://guide_examples/shared/ui_theme.tres" id="3_xcjwc"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/camera_2d.gd" id="3_xpjlw"]
|
||||
[ext_resource type="PackedScene" uid="uid://cj8m2n32yjxka" path="res://guide_examples/mouse_position_2d/godot_head.tscn" id="5_6xobh"]
|
||||
[ext_resource type="Resource" uid="uid://ehdejslyo58y" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/camera_movement.tres" id="5_snwnm"]
|
||||
[ext_resource type="Texture2D" uid="uid://slnmn5k0drdb" path="res://guide_examples/mouse_position_2d/background.svg" id="6_1tobk"]
|
||||
[ext_resource type="Script" path="res://guide_examples/mouse_position_2d/background.gd" id="7_4oihe"]
|
||||
[ext_resource type="Resource" uid="uid://6dm5j1sdhdp2" path="res://guide_examples/mouse_position_2d/mapping_contexts/actions/camera_zoom.tres" id="8_6tg1h"]
|
||||
[ext_resource type="Script" path="res://guide_examples/shared/instructions_label.gd" id="9_y8piq"]
|
||||
|
||||
[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="MousePosition" type="Node2D"]
|
||||
script = ExtResource("1_rkyn8")
|
||||
mapping_context = ExtResource("2_f4xly")
|
||||
spawn = ExtResource("3_e16oi")
|
||||
cursor = ExtResource("3_e2cui")
|
||||
godot_head_scene = ExtResource("5_6xobh")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
script = ExtResource("3_xpjlw")
|
||||
camera_movement = ExtResource("5_snwnm")
|
||||
camera_zoom = ExtResource("8_6tg1h")
|
||||
|
||||
[node name="BG" type="Sprite2D" parent="."]
|
||||
texture_repeat = 2
|
||||
material = SubResource("ShaderMaterial_1sa2x")
|
||||
texture = ExtResource("6_1tobk")
|
||||
centered = false
|
||||
script = ExtResource("7_4oihe")
|
||||
|
||||
[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("3_xcjwc")
|
||||
script = ExtResource("9_y8piq")
|
||||
instructions_text = "%s to move the camera.
|
||||
%s to zoom the camera.
|
||||
%s to place a Godot head."
|
||||
actions = Array[Resource("res://addons/guide/guide_action.gd")]([ExtResource("5_snwnm"), ExtResource("8_6tg1h"), ExtResource("3_e16oi")])
|
||||
|
||||
[node name="DebuggerLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="GuideDebugger" parent="DebuggerLayer" instance=ExtResource("2_yylue")]
|
||||
theme = ExtResource("3_xcjwc")
|
Reference in New Issue
Block a user