Skip to content
Carenalga edited this page Feb 7, 2023 · 3 revisions

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. none

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

    DOWN = 2 --- An arrow pointing down. down

    IDLE = 3 --- The default image. idle

    LEFT = 4 --- An arrow pointing left. left

    LOOK = 5 --- An eye. eye

    RIGHT = 6 --- An arrow pointing right. right

    SEARCH = 7 --- A magnifying glass. search

    TALK = 8 --- A dialog bubble. talk

    UP = 9 --- An arrow pointing up. up

    USE = 10 --- A pointing hand. use

    WAIT = 11 --- An hourglass. wait

Public

  • is_blocked bool If true the 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 ) void

    Scales 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, bool ignore_block = false ) void

    Changes the appearance of the cursor by one of the options (animations) defined in this class' enum Type. If ignore_block is true the 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, bool ignore_block = false ) void

    Assigns texture to a Sprite that will replace the default AnimatedSprite to show a texture as the cursor. If ignore_block is true the 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 ) void

    If is_visible is true then the cursor will be visible. Otherwise it will be hidden.

  • unlock() void

    Unlocks the cursor: is_blocked = false.

Clone this wiki locally