Item cursor composition
This commit is contained in:
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 428 B |
@@ -2,10 +2,22 @@ class_name RTMICursorManager
|
||||
|
||||
const RESIZE_RATIO: float = 0.7
|
||||
|
||||
const BASE_CURSOR := "res://addons/escoria-ui-return-monkey-island/cursors/base_item_cursor.png"
|
||||
|
||||
func set_cursor(texture: Texture2D) -> void:
|
||||
var image = texture.get_image()
|
||||
var resizeRatio = 100/image.get_width()
|
||||
|
||||
image.resize(image.get_width() * RESIZE_RATIO, image.get_height() * RESIZE_RATIO)
|
||||
Input.set_custom_mouse_cursor( image, Input.CURSOR_ARROW, Vector2(32,32))
|
||||
|
||||
var newTexture = Image.load_from_file(BASE_CURSOR)
|
||||
|
||||
var rect = Rect2i(Vector2i.ZERO, image.get_size())
|
||||
var textureOffset = Vector2i(10,10) #Vector2i.ZERO
|
||||
newTexture.blend_rect(image, rect, textureOffset)
|
||||
|
||||
# Hotspot es una coordenada x,y de dentro de la imagen.
|
||||
Input.set_custom_mouse_cursor( newTexture, Input.CURSOR_ARROW, Vector2i.ZERO)
|
||||
|
||||
func clear_cursor():
|
||||
Input.set_custom_mouse_cursor(null)
|
||||
|
||||
Reference in New Issue
Block a user