PopochiuClickable
Inherits: Area2D
Description
Base class for interactive objects that respond to mouse events.
This is the parent class for PopochiuProp, PopochiuHotspot, and PopochiuCharacter. It handles click detection, hover states, and provides a baseline system for rendering order. Two CollisionPolygon2D nodes are used: one for player interaction and one for scaling.
Properties
| Type | Name | Default |
|---|---|---|
| Variant | always_on_top | false |
| Variant | baseline | 0 |
| Variant | clickable | true |
| CURSOR | cursor | CURSOR.Type.NONE |
| Variant | description | "" |
| Variant | interaction_polygon | PackedVector2Array() |
| Variant | interaction_polygon_position | Vector2.ZERO |
| Variant | is_moving | false |
| Variant | last_click_button | -1 |
| Variant | look_at_point | Vector2.ZERO |
| Node2D | room | null |
| Variant | script_name | "" |
| Variant | times_clicked | 0 |
| Variant | times_double_clicked | 0 |
| Variant | times_middle_clicked | 0 |
| Variant | times_right_clicked | 0 |
| Variant | walk_to_point | Vector2.ZERO |
Methods
| Return Type | Method |
|---|---|
| void | _on_click() virtual |
| void | _on_double_click() virtual |
| void | _on_item_used(item: PopochiuInventoryItem) virtual |
| void | _on_middle_click() virtual |
| void | _on_movement_ended() virtual |
| void | _on_movement_started() virtual |
| void | _on_position_changed() virtual |
| void | _on_right_click() virtual |
| void | _on_room_set() virtual |
| int | count_invoked(command: int) |
| void | disable() |
| void | disable_clickable() |
| void | enable() |
| void | enable_clickable() |
| bool | ever_invoked(command: int) |
| bool | first_invoked(command: int) |
| String | get_description() |
| void | handle_command(button_idx: int) |
| bool | is_enabled() |
| void | move_to(pos: Vector2, speed: float = 100.0, transition_type: Tween.TransitionType = Tween.TRANS_LINEAR, ease_type: Tween.EaseType = Tween.EASE_IN_OUT) |
| void | on_click() |
| void | on_double_click() |
| void | on_item_used(item: PopochiuInventoryItem) |
| void | on_middle_click() |
| void | on_right_click() |
| Callable | queue_disable() |
| Callable | queue_disable_clickable() |
| Callable | queue_enable() |
| Callable | queue_enable_clickable() |
| Callable | queue_move_to(pos: Vector2, speed: float = 100.0, transition_type: Tween.TransitionType = Tween.TRANS_LINEAR, ease_type: Tween.EaseType = Tween.EASE_IN_OUT) |
| Callable | queue_teleport_to_hotspot(id: String, offset = Vector2.ZERO) |
| Callable | queue_teleport_to_marker(id: String, offset = Vector2.ZERO) |
| Callable | queue_teleport_to_position(pos: Vector2, offset = Vector2.ZERO) |
| Callable | queue_teleport_to_prop(id: String, offset = Vector2.ZERO) |
| void | set_clickable(value: bool) |
| void | set_room(value: Node2D) |
| void | teleport_to_hotspot(id: String, offset = Vector2.ZERO) |
| void | teleport_to_marker(id: String, offset = Vector2.ZERO) |
| void | teleport_to_position(pos: Vector2, offset: Vector2 = Vector2.ZERO) |
| void | teleport_to_prop(id: String, offset = Vector2.ZERO) |
Signals
Signal Descriptions
movement_ended
signal movement_ended()
Emitted when the clickable finishes moving or is repositioned.
movement_started
signal movement_started()
Emitted when the clickable starts moving.
Property Descriptions
always_on_top
@export var always_on_top = false
Whether the object will be rendered always above other objects in the room.
baseline
@export var baseline = 0
The y position of the baseline relative to the center of the object.
clickable
@export var clickable = true
- Setter:
set_clickable
Whether the object will react to interactions.
cursor
@export var cursor : CURSOR = CURSOR.Type.NONE
The cursor to use when the mouse hovers the object.
description
@export var description = ""
The text shown to players when the cursor hovers the object.
interaction_polygon
@export var interaction_polygon = PackedVector2Array()
Stores the vertices to assign to the InteractionPolygon child during runtime.
This is used by PopochiuRoom to store the info in its .tscn.
interaction_polygon_position
@export var interaction_polygon_position = Vector2.ZERO
Stores the position to assign to the InteractionPolygon child during runtime.
This is used by PopochiuRoom to store the info in its .tscn.
is_moving
var is_moving = false
Whether the clickable is currently moving via the move_to function.
last_click_button
var last_click_button = -1
Stores the last MouseButton pressed on this object.
look_at_point
@export var look_at_point = Vector2.ZERO
The Vector2 position where characters will turn looking at the object.
room
var room : Node2D = null
- Setter:
set_room
The PopochiuRoom to which the object belongs.
script_name
@export var script_name = ""
The identifier of the object used in scripts.
times_clicked
var times_clicked = 0
The number of times this object has been left-clicked.
times_double_clicked
var times_double_clicked = 0
The number of times this object has been double-clicked.
times_middle_clicked
var times_middle_clicked = 0
The number of times this object has been middle-clicked.
times_right_clicked
var times_right_clicked = 0
The number of times this object has been right-clicked.
walk_to_point
@export var walk_to_point = Vector2.ZERO
The Vector2 position where characters will move when approaching the object.
Method Descriptions
_on_click
func _on_click() -> void
This is a virtual method. Override it in your subclass.
Called when the node is clicked.
Override to implement custom click behavior.
_on_double_click
func _on_double_click() -> void
This is a virtual method. Override it in your subclass.
Called when the node is double-clicked.
Override to implement custom double click behavior.
_on_item_used
func _on_item_used(item: PopochiuInventoryItem) -> void
This is a virtual method. Override it in your subclass.
Called when the node is clicked and there is an active inventory item.
item is the currently selected (active) inventory item.
Override to implement custom behavior when an inventory item is used on this clickable.
_on_middle_click
func _on_middle_click() -> void
This is a virtual method. Override it in your subclass.
Called when the node is middle-clicked.
Override to implement custom middle click behavior.
_on_movement_ended
func _on_movement_ended() -> void
This is a virtual method. Override it in your subclass.
Called when the clickable stops moving.
_on_movement_started
func _on_movement_started() -> void
This is a virtual method. Override it in your subclass.
Called when the clickable starts moving.
_on_position_changed
func _on_position_changed() -> void
This is a virtual method. Override it in your subclass.
Called after the clickable's position changes to synchronize internal state.
This is intended to be overridden by child classes to update any internal variables. Use it in game scripts only if you know what you're doing.
_on_right_click
func _on_right_click() -> void
This is a virtual method. Override it in your subclass.
Called when the node is right-clicked.
Override to implement custom right click behavior.
_on_room_set
func _on_room_set() -> void
This is a virtual method. Override it in your subclass.
Called when the room containing this node is set.
count_invoked
func count_invoked(command: int) -> int
Returns the number of times the command has been invoked on this object.
disable
func disable() -> void
Hides and disables this node.
disable_clickable
func disable_clickable() -> void
Disables the clickable property and makes the object not input pickable.
enable
func enable() -> void
Shows and enables this node.
enable_clickable
func enable_clickable() -> void
Enables the clickable property and makes the object input pickable.
ever_invoked
func ever_invoked(command: int) -> bool
Returns true if the command has ever been invoked on this object.
This function is typically used in a command handler to provide different behaviors
depending on whether the command has been used before or not.
first_invoked
func first_invoked(command: int) -> bool
Returns true if this is the first time the command is being invoked on this object.
This function is typically used in a command handler to provide different behaviors
depending on whether the command has been used before or not.
get_description
func get_description() -> String
Returns the description of the node using tr() if
use_translations is true. Otherwise,
it returns just the value of description.
handle_command
func handle_command(button_idx: int) -> void
Triggers the proper GUI command for the clicked mouse button identified with button_idx,
which can be MouseButton.MOUSE_BUTTON_LEFT, MouseButton.MOUSE_BUTTON_RIGHT or
MouseButton.MOUSE_BUTTON_MIDDLE.
This is a plumbing method called by the engine when the object is clicked, and it's not intended for game scripts. Use it only if you know what you're doing.
is_enabled
func is_enabled() -> bool
Returns whether this object is currently enabled (visible, clickable and - for good measure - input pickable).
move_to
func move_to(pos: Vector2, speed: float = 100.0, transition_type: Tween.TransitionType = Tween.TRANS_LINEAR, ease_type: Tween.EaseType = Tween.EASE_IN_OUT) -> void
Smoothly moves the clickable to pos (absolute) in the current room.
speed sets the movement speed in pixels per second. transition_type and
ease_type control the tweening behavior.
Note: For PopochiuCharacter, this ignores walkable areas and doesn't affect
animation states.
on_click
func on_click() -> void
Called by the engine when the object is left clicked.
on_double_click
func on_double_click() -> void
Called by the engine when the object is double clicked.
on_item_used
func on_item_used(item: PopochiuInventoryItem) -> void
Called by the engine when an item is used on this object.
Using an items means clicking on the object while an inventory item is active.
on_middle_click
func on_middle_click() -> void
Called by the engine when the object is middle clicked.
on_right_click
func on_right_click() -> void
Called by the engine when the object is right clicked.
queue_disable
func queue_disable() -> Callable
Hides and disables this node.
This method is intended to be used inside a queue() of instructions.
queue_disable_clickable
func queue_disable_clickable() -> Callable
Disables the clickable property and makes the object not input pickable.
This method is intended to be used inside a queue() of instructions.
queue_enable
func queue_enable() -> Callable
Shows and enables this node.
This method is intended to be used inside a queue() of instructions.
queue_enable_clickable
func queue_enable_clickable() -> Callable
Enables the clickable property and makes the object input pickable.
This method is intended to be used inside a queue() of instructions.
queue_move_to
func queue_move_to(pos: Vector2, speed: float = 100.0, transition_type: Tween.TransitionType = Tween.TRANS_LINEAR, ease_type: Tween.EaseType = Tween.EASE_IN_OUT) -> Callable
Smoothly moves the clickable to pos (absolute)in the current room.
speed sets the movement speed in pixels per second. transition_type and
ease_type control the tweening behavior.
Note: For PopochiuCharacter, this ignores walkable areas and doesn't affect
animation states.
This method is intended to be used inside a queue() of instructions.
queue_teleport_to_hotspot
func queue_teleport_to_hotspot(id: String, offset = Vector2.ZERO) -> Callable
Instantly teleports the clickable to the PopochiuHotspot with matching id.
You can set an offset relative to the target position.
This method is intended to be used inside a queue() of instructions.
queue_teleport_to_marker
func queue_teleport_to_marker(id: String, offset = Vector2.ZERO) -> Callable
Instantly teleports the clickable to the Marker2D with matching id.
You can set an offset relative to the target position.
This method is intended to be used inside a queue() of instructions.
queue_teleport_to_position
func queue_teleport_to_position(pos: Vector2, offset = Vector2.ZERO) -> Callable
Instantly teleports the clickable to pos (absolute) in the current room.
You can set an offset relative to the target position.
This method is intended to be used inside a queue() of instructions.
queue_teleport_to_prop
func queue_teleport_to_prop(id: String, offset = Vector2.ZERO) -> Callable
Instantly teleports the clickable to the PopochiuProp with matching id.
You can set an offset relative to the target position.
This method is intended to be used inside a queue() of instructions.
set_clickable
func set_clickable(value: bool) -> void
set_room
func set_room(value: Node2D) -> void
teleport_to_hotspot
func teleport_to_hotspot(id: String, offset = Vector2.ZERO) -> void
Instantly teleports the clickable to the PopochiuHotspot with matching id.
You can set an offset relative to the target position.
teleport_to_marker
func teleport_to_marker(id: String, offset = Vector2.ZERO) -> void
Instantly teleports the clickable to the Marker2D with matching id.
You can set an offset relative to the target position.
teleport_to_position
func teleport_to_position(pos: Vector2, offset: Vector2 = Vector2.ZERO) -> void
Instantly teleports the clickable to pos (absolute) in the current room.
You can set an offset relative to the target position.
teleport_to_prop
func teleport_to_prop(id: String, offset = Vector2.ZERO) -> void
Instantly teleports the clickable to the PopochiuProp with matching id.
You can set an offset relative to the target position.