122 lines
3 KiB
Text
122 lines
3 KiB
Text
|
[gd_scene load_steps=8 format=3 uid="uid://524sv8spw6go"]
|
||
|
|
||
|
[ext_resource type="Texture2D" uid="uid://q1rdbr8uh78r" path="res://textures/cursor_default.tres" id="1_50ts1"]
|
||
|
[ext_resource type="Texture2D" uid="uid://bdstohvc7pvot" path="res://textures/cursor_click.tres" id="1_h0do2"]
|
||
|
[ext_resource type="Texture2D" uid="uid://buxws7r3kn0d7" path="res://textures/cursor_grab_01.tres" id="3_fj3w4"]
|
||
|
[ext_resource type="Texture2D" uid="uid://pbahcjllgjjq" path="res://textures/cursor_grab_02.tres" id="4_153q8"]
|
||
|
[ext_resource type="Texture2D" uid="uid://6fajq480n7se" path="res://textures/cursor_grab_03.tres" id="5_tsejy"]
|
||
|
|
||
|
[sub_resource type="GDScript" id="GDScript_h2l04"]
|
||
|
script/source = "extends Node2D
|
||
|
|
||
|
const Speed:float = 900
|
||
|
|
||
|
var spaceState
|
||
|
var query
|
||
|
var CastResult
|
||
|
var old_result
|
||
|
var selectedSticker
|
||
|
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
if not OS.is_debug_build():
|
||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED_HIDDEN)
|
||
|
query = PhysicsPointQueryParameters2D.new()
|
||
|
spaceState = get_world_2d()
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
func _process(delta):
|
||
|
|
||
|
#region Mouse Position
|
||
|
position = get_global_mouse_position()
|
||
|
#endregion
|
||
|
|
||
|
pointcast()
|
||
|
cursor_look()
|
||
|
|
||
|
|
||
|
func pointcast():
|
||
|
query.collide_with_areas = true
|
||
|
query.position = get_global_mouse_position()
|
||
|
CastResult = spaceState.direct_space_state.intersect_point(query)
|
||
|
if ( (CastResult.size() > 0) and (old_result != CastResult) ):
|
||
|
old_result = CastResult
|
||
|
for _result in CastResult:
|
||
|
if (_result.collider.input_pickable == true):
|
||
|
selectedSticker = _result.collider.get_parent()
|
||
|
print(\"selected sticker %\",selectedSticker)
|
||
|
|
||
|
|
||
|
if (CastResult.size() == 0):
|
||
|
CastResult.clear()
|
||
|
old_result = null
|
||
|
selectedSticker = null
|
||
|
|
||
|
func cursor_look():
|
||
|
$AnimatedSprite2D.play(\"default\")
|
||
|
if (Input.is_action_pressed(\"select\")):
|
||
|
if (selectedSticker):
|
||
|
$AnimatedSprite2D.play(\"grab\")
|
||
|
else:
|
||
|
$AnimatedSprite2D.play(\"click\")
|
||
|
else:
|
||
|
if (selectedSticker):
|
||
|
$AnimatedSprite2D.play(\"grab_intro\")
|
||
|
|
||
|
|
||
|
"
|
||
|
|
||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_u3xkr"]
|
||
|
resource_local_to_scene = true
|
||
|
animations = [{
|
||
|
"frames": [{
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("1_h0do2")
|
||
|
}],
|
||
|
"loop": true,
|
||
|
"name": &"click",
|
||
|
"speed": 5.0
|
||
|
}, {
|
||
|
"frames": [{
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("1_50ts1")
|
||
|
}],
|
||
|
"loop": true,
|
||
|
"name": &"default",
|
||
|
"speed": 5.0
|
||
|
}, {
|
||
|
"frames": [{
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("3_fj3w4")
|
||
|
}, {
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("4_153q8")
|
||
|
}, {
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("5_tsejy")
|
||
|
}],
|
||
|
"loop": true,
|
||
|
"name": &"grab",
|
||
|
"speed": 7.0
|
||
|
}, {
|
||
|
"frames": [{
|
||
|
"duration": 1.0,
|
||
|
"texture": ExtResource("3_fj3w4")
|
||
|
}],
|
||
|
"loop": true,
|
||
|
"name": &"grab_intro",
|
||
|
"speed": 5.0
|
||
|
}]
|
||
|
|
||
|
[node name="Cursor" type="Node2D"]
|
||
|
top_level = true
|
||
|
script = SubResource("GDScript_h2l04")
|
||
|
|
||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||
|
scale = Vector2(1.5, 1.5)
|
||
|
sprite_frames = SubResource("SpriteFrames_u3xkr")
|
||
|
animation = &"grab"
|
||
|
centered = false
|
||
|
offset = Vector2(-80, -190)
|