Update VisualScript demos for Godot 3.2

This commit is contained in:
Aaron Franke
2020-02-12 18:46:27 -05:00
parent 13ca65800d
commit da157f6d0e
9 changed files with 13 additions and 34 deletions

View File

@@ -4,34 +4,17 @@
[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" index="0"]
[node name="Sprite" type="Sprite"]
material = SubResource( 1 )
texture = ExtResource( 1 )
[node name="Area2D" type="Area2D" parent="." index="0"]
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"
[node name="Area2D" type="Area2D" parent="."]
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D" index="0"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource( 2 )

Binary file not shown.

View File

@@ -1,43 +1,39 @@
extends Node
# 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
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
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
elif event is InputEventScreenDrag: # Movement.
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

Binary file not shown.

Binary file not shown.

Binary file not shown.