cursor code

This commit is contained in:
Lucas Peter 2024-07-25 14:08:44 +02:00
parent 0f6f75e8c5
commit 7064af0707
No known key found for this signature in database
5 changed files with 63 additions and 4 deletions

36
core/Cursor.tscn Normal file
View file

@ -0,0 +1,36 @@
[gd_scene load_steps=4 format=3 uid="uid://524sv8spw6go"]
[ext_resource type="Texture2D" uid="uid://docoki1q4vvfh" path="res://textures/atlas/SPRT_Hand.png" id="1_va1hk"]
[sub_resource type="GDScript" id="GDScript_h2l04"]
script/source = "extends Node2D
const Speed:float = 900
# 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):
var mouse = get_viewport().get_mouse_position()
var old_pos
if (mouse != old_pos):
position = mouse
old_pos = position
"
[sub_resource type="AtlasTexture" id="AtlasTexture_n2i6f"]
atlas = ExtResource("1_va1hk")
region = Rect2(0, 0, 256, 256)
[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")
centered = false
offset = Vector2(-23.615, -235.42)

View file

@ -1,5 +1,7 @@
extends Node2D
@export var InitialPlayer :PackedScene
@export var InitialMap :PackedScene
@ -20,7 +22,7 @@ func transition_to_scene(new_scene: PackedScene, spawn_location = Vector2(0,0),
player = $CurrentScene.find_child("player",true)
if (player):
player.teleport(spawn_location, spawn_direction)
else:
else: #Spawn the player if there is none
if (InitialPlayer):
player = InitialPlayer.instantiate()
player.set_name("player")
@ -31,3 +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)

View file

@ -76,6 +76,26 @@ menu={
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
mouse_up={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null)
]
}
mouse_down={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null)
]
}
mouse_left={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null)
]
}
mouse_right={
"deadzone": 0.5,
"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null)
]
}
[layer_names]

View file

@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://docoki1q4vvfh"
path="res://.godot/imported/SPRT_Hand.png-10f10cc13ae4b0331523734719309ebe.ctex"
path="res://.godot/imported/SPRT_Hand.png-f682339cd646a6350ee80c8d3fc09b3b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://extracted/Texture2D/SPRT_Hand.png"
dest_files=["res://.godot/imported/SPRT_Hand.png-10f10cc13ae4b0331523734719309ebe.ctex"]
source_file="res://textures/atlas/SPRT_Hand.png"
dest_files=["res://.godot/imported/SPRT_Hand.png-f682339cd646a6350ee80c8d3fc09b3b.ctex"]
[params]