cursor code
This commit is contained in:
parent
0f6f75e8c5
commit
7064af0707
5 changed files with 63 additions and 4 deletions
36
core/Cursor.tscn
Normal file
36
core/Cursor.tscn
Normal 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)
|
|
@ -1,5 +1,7 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@export var InitialPlayer :PackedScene
|
@export var InitialPlayer :PackedScene
|
||||||
@export var InitialMap :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)
|
player = $CurrentScene.find_child("player",true)
|
||||||
if (player):
|
if (player):
|
||||||
player.teleport(spawn_location, spawn_direction)
|
player.teleport(spawn_location, spawn_direction)
|
||||||
else:
|
else: #Spawn the player if there is none
|
||||||
if (InitialPlayer):
|
if (InitialPlayer):
|
||||||
player = InitialPlayer.instantiate()
|
player = InitialPlayer.instantiate()
|
||||||
player.set_name("player")
|
player.set_name("player")
|
||||||
|
@ -31,3 +33,4 @@ func transition_to_scene(new_scene: PackedScene, spawn_location = Vector2(0,0),
|
||||||
|
|
||||||
func _on_ready():
|
func _on_ready():
|
||||||
transition_to_scene(InitialMap,Vector2(0,0),1)
|
transition_to_scene(InitialMap,Vector2(0,0),1)
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
|
@ -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)
|
, 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]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://docoki1q4vvfh"
|
uid="uid://docoki1q4vvfh"
|
||||||
path="res://.godot/imported/SPRT_Hand.png-10f10cc13ae4b0331523734719309ebe.ctex"
|
path="res://.godot/imported/SPRT_Hand.png-f682339cd646a6350ee80c8d3fc09b3b.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://extracted/Texture2D/SPRT_Hand.png"
|
source_file="res://textures/atlas/SPRT_Hand.png"
|
||||||
dest_files=["res://.godot/imported/SPRT_Hand.png-10f10cc13ae4b0331523734719309ebe.ctex"]
|
dest_files=["res://.godot/imported/SPRT_Hand.png-f682339cd646a6350ee80c8d3fc09b3b.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
Loading…
Reference in a new issue