Cursor - carenalgas/popochiu GitHub Wiki
Description
Functions and data for manipulating the mouse cursor. Is the shortcut for Cursor.gd, and can be used (from any script) with Cursor (E.g. Cursor.set_cursor(Cursor.Type.TALK)).
The cursor's appeareance in Popochiu is an AnimatedSprite which animations are linked to a state defined by this class' enum Type. It also has a Sprite that will be visible when using another texture as the cursor appeareance (this is the case of showing the active inventory item).
Some things you can do with it:
- Show or hide the cursor.
- Block it or unlock it.
- Set a texture as the image for the cursor.
- Change the cursor to one of the types available by default.
Examples
Cursor.toggle_visibility(false) # Hide the cursor
Cursor.block() # The cursor can't change its appeareance
Cursor.set_item_cursor(I.active.texture) # Make the cursor look as the current selected item in the inventory
Properties
Enumerations
-
Type
NONE = 0 --- A small cross.

ACTIVE = 1 --- To show an object has interaction.

DOWN = 2 --- An arrow pointing down.

IDLE = 3 --- The default image.

LEFT = 4 --- An arrow pointing left.

LOOK = 5 --- An eye.

RIGHT = 6 --- An arrow pointing right.

SEARCH = 7 --- A magnifying glass.

TALK = 8 --- A dialog bubble.

UP = 9 --- An arrow pointing up.

USE = 10 --- A pointing hand.

WAIT = 11 --- An hourglass.

Public
- is_blocked bool If
truethe cursor won't change its appearance.
Methods
Public
-
block() void
Blocks the cursor:
is_blocked = true. -
remove_cursor_texture() void
Hides the texture set by set_cursor_texture() and shows the default AnimatedSprite.
-
scale_cursor( Vector2
factor) voidScales the Sprite and AnimatedSprite childs of this scene to
factor. Used by Popochiu when the game is scaled based on the viewport size. -
set_cursor( int
type = Type.IDLE, boolignore_block = false) voidChanges the appearance of the cursor by one of the options (animations) defined in this class'
enum Type. Ifignore_blockistruethe cursor texture will change no matter the graphic interface is blocked (that is when, by default, the cursor texture is an hourglass). -
set_cursor_texture( Texture
texture, boolignore_block = false) voidAssigns
textureto a Sprite that will replace the default AnimatedSprite to show a texture as the cursor. Ifignore_blockistruethe cursor texture will change no matter the graphic interface is blocked (that is when, by default, the cursor texture is an hourglass). -
toggle_visibility( bool
is_visible) voidIf
is_visibleistruethen the cursor will be visible. Otherwise it will be hidden. -
unlock() void
Unlocks the cursor:
is_blocked = false.