mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-07 08:20:11 +01:00
Merge pull request #172 from RandomShaper/adpod-mt
Examples about (multi)touch events
This commit is contained in:
37
visual_script/circle_pop/Circle.tscn
Normal file
37
visual_script/circle_pop/Circle.tscn
Normal file
@@ -0,0 +1,37 @@
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://white-circle.png" type="Texture" id=1]
|
||||
[ext_resource path="res://CircleArea.vs" type="Script" id=2]
|
||||
|
||||
[sub_resource type="CanvasItemMaterial" id=1]
|
||||
|
||||
render_priority = 0
|
||||
blend_mode = 1
|
||||
light_mode = 0
|
||||
|
||||
[sub_resource type="CircleShape2D" id=2]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
radius = 128.0
|
||||
|
||||
[node name="Sprite" type="Sprite"]
|
||||
|
||||
material = SubResource( 1 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="Area2D" type="Area2D" parent="."]
|
||||
|
||||
input_pickable = true
|
||||
gravity_vec = Vector2( 0, 1 )
|
||||
gravity = 98.0
|
||||
linear_damp = 0.1
|
||||
angular_damp = 1.0
|
||||
audio_bus_override = false
|
||||
audio_bus_name = "Master"
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||
|
||||
shape = SubResource( 2 )
|
||||
|
||||
|
||||
BIN
visual_script/circle_pop/CircleArea.vs
Normal file
BIN
visual_script/circle_pop/CircleArea.vs
Normal file
Binary file not shown.
18
visual_script/circle_pop/Main.tscn
Normal file
18
visual_script/circle_pop/Main.tscn
Normal file
@@ -0,0 +1,18 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Main.vs" type="Script" id=1]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
|
||||
process_mode = 1
|
||||
wait_time = 1.0
|
||||
one_shot = false
|
||||
autostart = true
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
||||
|
||||
BIN
visual_script/circle_pop/Main.vs
Normal file
BIN
visual_script/circle_pop/Main.vs
Normal file
Binary file not shown.
101
visual_script/circle_pop/default_env.tres
Normal file
101
visual_script/circle_pop/default_env.tres
Normal file
@@ -0,0 +1,101 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
radiance_size = 4
|
||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||
sky_curve = 0.25
|
||||
sky_energy = 1.0
|
||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||
ground_curve = 0.01
|
||||
ground_energy = 1.0
|
||||
sun_color = Color( 1, 1, 1, 1 )
|
||||
sun_latitude = 35.0
|
||||
sun_longitude = 0.0
|
||||
sun_angle_min = 1.0
|
||||
sun_angle_max = 100.0
|
||||
sun_curve = 0.05
|
||||
sun_energy = 16.0
|
||||
texture_size = 2
|
||||
|
||||
[resource]
|
||||
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
background_sky_custom_fov = 0.0
|
||||
background_color = Color( 0, 0, 0, 1 )
|
||||
background_energy = 1.0
|
||||
background_canvas_max_layer = 0
|
||||
ambient_light_color = Color( 0, 0, 0, 1 )
|
||||
ambient_light_energy = 1.0
|
||||
ambient_light_sky_contribution = 1.0
|
||||
fog_enabled = false
|
||||
fog_color = Color( 0.5, 0.6, 0.7, 1 )
|
||||
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
|
||||
fog_sun_amount = 0.0
|
||||
fog_depth_enabled = true
|
||||
fog_depth_begin = 10.0
|
||||
fog_depth_curve = 1.0
|
||||
fog_transmit_enabled = false
|
||||
fog_transmit_curve = 1.0
|
||||
fog_height_enabled = false
|
||||
fog_height_min = 0.0
|
||||
fog_height_max = 100.0
|
||||
fog_height_curve = 1.0
|
||||
tonemap_mode = 0
|
||||
tonemap_exposure = 1.0
|
||||
tonemap_white = 1.0
|
||||
auto_exposure_enabled = false
|
||||
auto_exposure_scale = 0.4
|
||||
auto_exposure_min_luma = 0.05
|
||||
auto_exposure_max_luma = 8.0
|
||||
auto_exposure_speed = 0.5
|
||||
ss_reflections_enabled = false
|
||||
ss_reflections_max_steps = 64
|
||||
ss_reflections_fade_in = 0.15
|
||||
ss_reflections_fade_out = 2.0
|
||||
ss_reflections_depth_tolerance = 0.2
|
||||
ss_reflections_roughness = true
|
||||
ssao_enabled = false
|
||||
ssao_radius = 1.0
|
||||
ssao_intensity = 1.0
|
||||
ssao_radius2 = 0.0
|
||||
ssao_intensity2 = 1.0
|
||||
ssao_bias = 0.01
|
||||
ssao_light_affect = 0.0
|
||||
ssao_color = Color( 0, 0, 0, 1 )
|
||||
ssao_quality = 0
|
||||
ssao_blur = 3
|
||||
ssao_edge_sharpness = 4.0
|
||||
dof_blur_far_enabled = false
|
||||
dof_blur_far_distance = 10.0
|
||||
dof_blur_far_transition = 5.0
|
||||
dof_blur_far_amount = 0.1
|
||||
dof_blur_far_quality = 1
|
||||
dof_blur_near_enabled = false
|
||||
dof_blur_near_distance = 2.0
|
||||
dof_blur_near_transition = 1.0
|
||||
dof_blur_near_amount = 0.1
|
||||
dof_blur_near_quality = 1
|
||||
glow_enabled = false
|
||||
glow_levels/1 = false
|
||||
glow_levels/2 = false
|
||||
glow_levels/3 = true
|
||||
glow_levels/4 = false
|
||||
glow_levels/5 = true
|
||||
glow_levels/6 = false
|
||||
glow_levels/7 = false
|
||||
glow_intensity = 0.8
|
||||
glow_strength = 1.0
|
||||
glow_bloom = 0.0
|
||||
glow_blend_mode = 2
|
||||
glow_hdr_threshold = 1.0
|
||||
glow_hdr_scale = 2.0
|
||||
glow_bicubic_upscale = false
|
||||
adjustment_enabled = false
|
||||
adjustment_brightness = 1.0
|
||||
adjustment_contrast = 1.0
|
||||
adjustment_saturation = 1.0
|
||||
|
||||
BIN
visual_script/circle_pop/icon.png
Normal file
BIN
visual_script/circle_pop/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
24
visual_script/circle_pop/project.godot
Normal file
24
visual_script/circle_pop/project.godot
Normal file
@@ -0,0 +1,24 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=3
|
||||
|
||||
[application]
|
||||
|
||||
config/name="CirclePop"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_clear_color=Color( 0.113725, 0.133333, 0.196078, 1 )
|
||||
environment/default_environment="res://default_env.tres"
|
||||
BIN
visual_script/circle_pop/white-circle.png
Normal file
BIN
visual_script/circle_pop/white-circle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
9
visual_script/multitouch_view/Main.tscn
Normal file
9
visual_script/multitouch_view/Main.tscn
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://Main.vs" type="Script" id=1]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
|
||||
script = ExtResource( 1 )
|
||||
|
||||
|
||||
BIN
visual_script/multitouch_view/Main.vs
Normal file
BIN
visual_script/multitouch_view/Main.vs
Normal file
Binary file not shown.
43
visual_script/multitouch_view/TouchHelper.gd
Normal file
43
visual_script/multitouch_view/TouchHelper.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
# This will track the position of every pointer in its public `state` property, which is a
|
||||
# Dictionary, in which each key is a pointer id (integer) and each value its position (Vector2).
|
||||
# It works by listening to input events not handled by other means.
|
||||
# It also remaps the pointer indices coming from the OS to the lowest available to be friendlier.
|
||||
# It can be conveniently setup as a singleton.
|
||||
|
||||
extends Node
|
||||
|
||||
var state = {}
|
||||
var _os2own = {}
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventScreenTouch:
|
||||
if event.pressed:
|
||||
# Down
|
||||
if !_os2own.has(event.index): # Defensively discard index if already known
|
||||
var ptr_id = _find_free_pointer_id()
|
||||
state[ptr_id] = event.position
|
||||
_os2own[event.index] = ptr_id
|
||||
else:
|
||||
# Up
|
||||
if _os2own.has(event.index): # Defensively discard index if not known
|
||||
var ptr_id = _os2own[event.index]
|
||||
state.erase(ptr_id)
|
||||
_os2own.erase(event.index)
|
||||
return true
|
||||
|
||||
elif event is InputEventScreenDrag:
|
||||
# Move
|
||||
if _os2own.has(event.index): # Defensively discard index if not known
|
||||
var ptr_id = _os2own[event.index]
|
||||
state[ptr_id] = event.position
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _find_free_pointer_id():
|
||||
var used = state.keys()
|
||||
var i = 0
|
||||
while i in used:
|
||||
i += 1
|
||||
return i
|
||||
|
||||
101
visual_script/multitouch_view/default_env.tres
Normal file
101
visual_script/multitouch_view/default_env.tres
Normal file
@@ -0,0 +1,101 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
radiance_size = 4
|
||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||
sky_curve = 0.25
|
||||
sky_energy = 1.0
|
||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||
ground_curve = 0.01
|
||||
ground_energy = 1.0
|
||||
sun_color = Color( 1, 1, 1, 1 )
|
||||
sun_latitude = 35.0
|
||||
sun_longitude = 0.0
|
||||
sun_angle_min = 1.0
|
||||
sun_angle_max = 100.0
|
||||
sun_curve = 0.05
|
||||
sun_energy = 16.0
|
||||
texture_size = 2
|
||||
|
||||
[resource]
|
||||
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
background_sky_custom_fov = 0.0
|
||||
background_color = Color( 0, 0, 0, 1 )
|
||||
background_energy = 1.0
|
||||
background_canvas_max_layer = 0
|
||||
ambient_light_color = Color( 0, 0, 0, 1 )
|
||||
ambient_light_energy = 1.0
|
||||
ambient_light_sky_contribution = 1.0
|
||||
fog_enabled = false
|
||||
fog_color = Color( 0.5, 0.6, 0.7, 1 )
|
||||
fog_sun_color = Color( 1, 0.9, 0.7, 1 )
|
||||
fog_sun_amount = 0.0
|
||||
fog_depth_enabled = true
|
||||
fog_depth_begin = 10.0
|
||||
fog_depth_curve = 1.0
|
||||
fog_transmit_enabled = false
|
||||
fog_transmit_curve = 1.0
|
||||
fog_height_enabled = false
|
||||
fog_height_min = 0.0
|
||||
fog_height_max = 100.0
|
||||
fog_height_curve = 1.0
|
||||
tonemap_mode = 0
|
||||
tonemap_exposure = 1.0
|
||||
tonemap_white = 1.0
|
||||
auto_exposure_enabled = false
|
||||
auto_exposure_scale = 0.4
|
||||
auto_exposure_min_luma = 0.05
|
||||
auto_exposure_max_luma = 8.0
|
||||
auto_exposure_speed = 0.5
|
||||
ss_reflections_enabled = false
|
||||
ss_reflections_max_steps = 64
|
||||
ss_reflections_fade_in = 0.15
|
||||
ss_reflections_fade_out = 2.0
|
||||
ss_reflections_depth_tolerance = 0.2
|
||||
ss_reflections_roughness = true
|
||||
ssao_enabled = false
|
||||
ssao_radius = 1.0
|
||||
ssao_intensity = 1.0
|
||||
ssao_radius2 = 0.0
|
||||
ssao_intensity2 = 1.0
|
||||
ssao_bias = 0.01
|
||||
ssao_light_affect = 0.0
|
||||
ssao_color = Color( 0, 0, 0, 1 )
|
||||
ssao_quality = 0
|
||||
ssao_blur = 3
|
||||
ssao_edge_sharpness = 4.0
|
||||
dof_blur_far_enabled = false
|
||||
dof_blur_far_distance = 10.0
|
||||
dof_blur_far_transition = 5.0
|
||||
dof_blur_far_amount = 0.1
|
||||
dof_blur_far_quality = 1
|
||||
dof_blur_near_enabled = false
|
||||
dof_blur_near_distance = 2.0
|
||||
dof_blur_near_transition = 1.0
|
||||
dof_blur_near_amount = 0.1
|
||||
dof_blur_near_quality = 1
|
||||
glow_enabled = false
|
||||
glow_levels/1 = false
|
||||
glow_levels/2 = false
|
||||
glow_levels/3 = true
|
||||
glow_levels/4 = false
|
||||
glow_levels/5 = true
|
||||
glow_levels/6 = false
|
||||
glow_levels/7 = false
|
||||
glow_intensity = 0.8
|
||||
glow_strength = 1.0
|
||||
glow_bloom = 0.0
|
||||
glow_blend_mode = 2
|
||||
glow_hdr_threshold = 1.0
|
||||
glow_hdr_scale = 2.0
|
||||
glow_bicubic_upscale = false
|
||||
adjustment_enabled = false
|
||||
adjustment_brightness = 1.0
|
||||
adjustment_contrast = 1.0
|
||||
adjustment_saturation = 1.0
|
||||
|
||||
BIN
visual_script/multitouch_view/icon.png
Normal file
BIN
visual_script/multitouch_view/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
28
visual_script/multitouch_view/project.godot
Normal file
28
visual_script/multitouch_view/project.godot
Normal file
@@ -0,0 +1,28 @@
|
||||
; Engine configuration file.
|
||||
; It's best edited using the editor UI and not directly,
|
||||
; since the parameters that go here are not all obvious.
|
||||
;
|
||||
; Format:
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=3
|
||||
|
||||
[application]
|
||||
|
||||
config/name="TouchesView"
|
||||
run/main_scene="res://Main.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
TouchHelper="*res://TouchHelper.gd"
|
||||
|
||||
[gdnative]
|
||||
|
||||
singletons=[ ]
|
||||
|
||||
[rendering]
|
||||
|
||||
environment/default_clear_color=Color( 0.113725, 0.133333, 0.196078, 1 )
|
||||
environment/default_environment="res://default_env.tres"
|
||||
Reference in New Issue
Block a user