add custom cursor
This commit is contained in:
parent
727e147e8b
commit
ddd0fdff22
2 changed files with 13 additions and 0 deletions
|
@ -21,6 +21,7 @@ window/size/viewport_width=640
|
||||||
window/size/viewport_height=320
|
window/size/viewport_height=320
|
||||||
window/size/mode=2
|
window/size/mode=2
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
|
mouse_cursor/custom_image="res://textures/cursor_normal.png"
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@ var target_scale
|
||||||
var current_selected = "none"
|
var current_selected = "none"
|
||||||
var target_scale_player: Vector2 = Vector2(1, 1)
|
var target_scale_player: Vector2 = Vector2(1, 1)
|
||||||
|
|
||||||
|
var cursor_scale_up = preload("res://textures/cursor_scale_up.png")
|
||||||
|
var cursor_scale_down = preload("res://textures/cursor_scale_down.png")
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
data_link = $data_link
|
data_link = $data_link
|
||||||
|
|
||||||
|
@ -78,6 +81,7 @@ func _physics_process(delta):
|
||||||
velocity.y += gravity
|
velocity.y += gravity
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
update_data_link()
|
update_data_link()
|
||||||
|
update_cursor()
|
||||||
|
|
||||||
func Jump():
|
func Jump():
|
||||||
velocity.y = -1 * jump_strength
|
velocity.y = -1 * jump_strength
|
||||||
|
@ -96,6 +100,14 @@ func update_data_link():
|
||||||
else:
|
else:
|
||||||
data_link.visible = false
|
data_link.visible = false
|
||||||
|
|
||||||
|
func update_cursor():
|
||||||
|
var nearest_block = find_nearest_block()
|
||||||
|
if nearest_block:
|
||||||
|
if nearest_block.scale == Vector2(0.5, 0.5) and self.scale == Vector2(2.0, 2.0):
|
||||||
|
Input.set_custom_mouse_cursor(cursor_scale_up)
|
||||||
|
elif nearest_block.scale == Vector2(1.0, 1.0) and self.scale == Vector2(1.0, 1.0):
|
||||||
|
Input.set_custom_mouse_cursor(cursor_scale_down)
|
||||||
|
|
||||||
func find_nearest_block() -> Node2D:
|
func find_nearest_block() -> Node2D:
|
||||||
if not get_tree():
|
if not get_tree():
|
||||||
return null
|
return null
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue