PopochiuCursor

Inherits: CanvasLayer

Description

Legacy cursor Type enum kept for compatibility with older code and creation popups. Values represent named cursor states used by the UI.


Properties

Type Name Default
Variant is_blocked false
Variant is_pixel_perfect false

Methods

Return Type Method
void block()
int get_cursor_height()
Vector2 get_position()
String get_type_name(idx: int)
void hide_main_cursor()
void hide_secondary_cursor()
void remove_secondary_cursor_texture()
void replace_frames(new_node: AnimatedSprite2D)
void scale_cursor(factor: Vector2)
void set_secondary_cursor_texture(texture: Texture2D, ignore_block = false)
void show_cursor(anim_name = "normal", ignore_block = false)
void show_main_cursor()
void show_secondary_cursor()
void toggle_visibility(is_visible: bool)
void unblock()

Enumerations


Enumeration Descriptions

enum Type

enum Type {
    NONE,
    ACTIVE,
    DOWN,
    IDLE,
    LEFT,
    LOOK,
    RIGHT,
    SEARCH,
    TALK,
    UP,
    USE,
    WAIT,
}

Property Descriptions

is_blocked

var is_blocked = false

When true, methods that respect blocking (for example show_cursor() and set_secondary_cursor_texture()) will ignore requests unless their ignore_block parameter is true.


is_pixel_perfect

@export var is_pixel_perfect = false

When true, cursor positions are snapped to integer pixels (using Vector2i) to produce a pixel-perfect cursor. When false, cursor positions use floating-point Vector2 coordinates allowing sub-pixel positioning.


Method Descriptions

block

func block() -> void

Causes the cursor to enter a blocked state. While blocked, cursor update calls that respect blocking (for example show_cursor and set_secondary_cursor_texture) are ignored unless their ignore_block parameter is used.


get_cursor_height

func get_cursor_height() -> int

Returns the current cursor height in pixels as an [int]. Uses the visible cursor's texture height. If the main cursor is visible uses its current frame height, otherwise the secondary cursor texture is used.


get_position

func get_position() -> Vector2

Returns the current cursor position as a Vector2.


get_type_name

func get_type_name(idx: int) -> String

Returns the snake_case name of the cursor Type at index idx as a String.


hide_main_cursor

func hide_main_cursor() -> void

Hides the main cursor.


hide_secondary_cursor

func hide_secondary_cursor() -> void

Hides the secondary cursor.


remove_secondary_cursor_texture

func remove_secondary_cursor_texture() -> void

Removes the secondary cursor texture.

Restores default scale when GUI scaling (experimental) is enabled.


replace_frames

func replace_frames(new_node: AnimatedSprite2D) -> void

Replaces the main cursor sprite frames (and offset) with those from new_node (AnimatedSprite2D).


scale_cursor

func scale_cursor(factor: Vector2) -> void

Scale both main and secondary cursors by a factor (Vector2).


set_secondary_cursor_texture

func set_secondary_cursor_texture(texture: Texture2D, ignore_block = false) -> void

Sets the secondary cursor texture to texture. If the cursor is blocked the call is ignored, unless ignore_block is true.

When e.settings.scale_gui (experimental) is enabled, the texture is scaled relative to the main cursor height.


show_cursor

func show_cursor(anim_name = "normal", ignore_block = false) -> void

Shows the cursor using anim_name. If the cursor is blocked the call is ignored, unless ignore_block is true. If the animation does not exist, an error is logged.


show_main_cursor

func show_main_cursor() -> void

Shows the main cursor.


show_secondary_cursor

func show_secondary_cursor() -> void

Shows the secondary cursor.


toggle_visibility

func toggle_visibility(is_visible: bool) -> void

Sets visibility of both main and secondary cursors to is_visible.


unblock

func unblock() -> void

Clears the cursor blocked state, allowing cursor methods to update the cursor again. This does not change the current cursor animation or texture.