Cursor work
This commit is contained in:
parent
7064af0707
commit
2d87d3beab
10 changed files with 234 additions and 19 deletions
101
core/Cursor.tscn
101
core/Cursor.tscn
|
@ -1,36 +1,109 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://524sv8spw6go"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://524sv8spw6go"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_va1hk"]
|
||||
[ext_resource type="Texture2D" uid="uid://q1rdbr8uh78r" path="res://textures/cursor_default.tres" id="1_50ts1"]
|
||||
[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():
|
||||
pass # Replace with function body.
|
||||
|
||||
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):
|
||||
var mouse = get_viewport().get_mouse_position()
|
||||
|
||||
#region Mouse Position
|
||||
var old_pos
|
||||
if (mouse != old_pos):
|
||||
position = mouse
|
||||
#if (get_global_mouse_position() != old_pos):
|
||||
position = get_global_mouse_position()
|
||||
old_pos = 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():
|
||||
if (selectedSticker):
|
||||
$AnimatedSprite2D.play(\"grab_intro\")
|
||||
|
||||
else:
|
||||
$AnimatedSprite2D.play(\"default\")
|
||||
"
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_n2i6f"]
|
||||
atlas = ExtResource("1_va1hk")
|
||||
region = Rect2(0, 0, 256, 256)
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_u3xkr"]
|
||||
resource_local_to_scene = true
|
||||
animations = [{
|
||||
"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": false,
|
||||
"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="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.5, 0.5)
|
||||
texture = SubResource("AtlasTexture_n2i6f")
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
scale = Vector2(1.5, 1.5)
|
||||
sprite_frames = SubResource("SpriteFrames_u3xkr")
|
||||
autoplay = "default"
|
||||
centered = false
|
||||
offset = Vector2(-23.615, -235.42)
|
||||
offset = Vector2(-80, -190)
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
[gd_scene format=3 uid="uid://kbso0l2uk2n7"]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://kbso0l2uk2n7"]
|
||||
|
||||
[node name="Sticker" type="Node"]
|
||||
[sub_resource type="GDScript" id="GDScript_4kxk0"]
|
||||
script/source = "extends Area2D
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
|
||||
|
||||
func _on_mouse_entered():
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_mouse_exited():
|
||||
pass # Replace with function body.
|
||||
"
|
||||
|
||||
[node name="StickerDetection" type="Area2D"]
|
||||
monitoring = false
|
||||
script = SubResource("GDScript_4kxk0")
|
||||
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||
|
|
|
@ -33,4 +33,4 @@ func transition_to_scene(new_scene: PackedScene, spawn_location = Vector2(0,0),
|
|||
|
||||
func _on_ready():
|
||||
transition_to_scene(InitialMap,Vector2(0,0),1)
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
|
|
63
export_presets.cfg
Normal file
63
export_presets.cfg
Normal file
|
@ -0,0 +1,63 @@
|
|||
[preset.0]
|
||||
|
||||
name="StickerCole"
|
||||
platform="Windows Desktop"
|
||||
runnable=true
|
||||
dedicated_server=false
|
||||
custom_features=""
|
||||
export_filter="scenes"
|
||||
export_files=PackedStringArray("res://maps/mainMenu.tscn", "res://maps/map1.tscn", "res://maps/mapManager.tscn")
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path="builds/stickerClone.exe"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
encrypt_directory=false
|
||||
|
||||
[preset.0.options]
|
||||
|
||||
custom_template/debug=""
|
||||
custom_template/release=""
|
||||
debug/export_console_wrapper=1
|
||||
binary_format/embed_pck=false
|
||||
texture_format/bptc=true
|
||||
texture_format/s3tc=true
|
||||
texture_format/etc=false
|
||||
texture_format/etc2=false
|
||||
binary_format/architecture="x86_64"
|
||||
codesign/enable=false
|
||||
codesign/timestamp=true
|
||||
codesign/timestamp_server_url=""
|
||||
codesign/digest_algorithm=1
|
||||
codesign/description=""
|
||||
codesign/custom_options=PackedStringArray()
|
||||
application/modify_resources=true
|
||||
application/icon=""
|
||||
application/console_wrapper_icon=""
|
||||
application/icon_interpolation=4
|
||||
application/file_version=""
|
||||
application/product_version=""
|
||||
application/company_name=""
|
||||
application/product_name=""
|
||||
application/file_description=""
|
||||
application/copyright=""
|
||||
application/trademarks=""
|
||||
application/export_angle=0
|
||||
ssh_remote_deploy/enabled=false
|
||||
ssh_remote_deploy/host="user@host_ip"
|
||||
ssh_remote_deploy/port="22"
|
||||
ssh_remote_deploy/extra_args_ssh=""
|
||||
ssh_remote_deploy/extra_args_scp=""
|
||||
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
|
||||
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
|
||||
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
|
||||
$settings = New-ScheduledTaskSettingsSet
|
||||
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
|
||||
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
|
||||
Start-ScheduledTask -TaskName godot_remote_debug
|
||||
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
|
||||
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
|
||||
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
|
||||
Remove-Item -Recurse -Force '{temp_dir}'"
|
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://d382cexpr4075"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d382cexpr4075"]
|
||||
|
||||
[ext_resource type="Script" path="res://core/sceneInstance.gd" id="1_p0vo1"]
|
||||
[ext_resource type="PackedScene" uid="uid://0m1hk2nu4bps" path="res://core/player.tscn" id="2_fyjh8"]
|
||||
[ext_resource type="PackedScene" uid="uid://wlqsvbqpcbh" path="res://maps/map1.tscn" id="2_qgqfi"]
|
||||
[ext_resource type="PackedScene" uid="uid://524sv8spw6go" path="res://core/Cursor.tscn" id="4_uwedi"]
|
||||
|
||||
[node name="MapManager" type="Node2D"]
|
||||
script = ExtResource("1_p0vo1")
|
||||
|
@ -11,4 +12,6 @@ InitialMap = ExtResource("2_qgqfi")
|
|||
|
||||
[node name="CurrentScene" type="Node2D" parent="."]
|
||||
|
||||
[node name="Cursor" parent="." instance=ExtResource("4_uwedi")]
|
||||
|
||||
[connection signal="ready" from="." to="." method="_on_ready"]
|
||||
|
|
7
textures/cursor_default.tres
Normal file
7
textures/cursor_default.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://q1rdbr8uh78r"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_n6y0a"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_n6y0a")
|
||||
region = Rect2(0, 0, 256, 256)
|
21
textures/cursor_grab.tres
Normal file
21
textures/cursor_grab.tres
Normal file
|
@ -0,0 +1,21 @@
|
|||
[gd_resource type="AnimatedTexture" load_steps=5 format=3 uid="uid://sgwck5ca17s1"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://q1rdbr8uh78r" path="res://textures/cursor_default.tres" id="1_k7xih"]
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_ltia2"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gpt2k"]
|
||||
atlas = ExtResource("1_ltia2")
|
||||
region = Rect2(0, 256, 256, 256)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hq7jx"]
|
||||
atlas = ExtResource("1_ltia2")
|
||||
region = Rect2(256, 256, 256, 256)
|
||||
|
||||
[resource]
|
||||
frames = 3
|
||||
frame_0/texture = ExtResource("1_k7xih")
|
||||
frame_0/duration = 0.5
|
||||
frame_1/texture = SubResource("AtlasTexture_gpt2k")
|
||||
frame_1/duration = 0.5
|
||||
frame_2/texture = SubResource("AtlasTexture_hq7jx")
|
||||
frame_2/duration = 0.5
|
7
textures/cursor_grab_01.tres
Normal file
7
textures/cursor_grab_01.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://buxws7r3kn0d7"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_xhy8h"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_xhy8h")
|
||||
region = Rect2(256, 0, 256, 256)
|
7
textures/cursor_grab_02.tres
Normal file
7
textures/cursor_grab_02.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://pbahcjllgjjq"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_it2wc"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_it2wc")
|
||||
region = Rect2(0, 256, 256, 256)
|
7
textures/cursor_grab_03.tres
Normal file
7
textures/cursor_grab_03.tres
Normal file
|
@ -0,0 +1,7 @@
|
|||
[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://6fajq480n7se"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_r8woc"]
|
||||
|
||||
[resource]
|
||||
atlas = ExtResource("1_r8woc")
|
||||
region = Rect2(256, 256, 256, 256)
|
Loading…
Reference in a new issue