PopochiuCharacter

Extends: PopochiuClickable

Description

Constants Descriptions

FlipsWhen

enum FlipsWhen{NONE = 0, LOOKING_RIGHT = 1, LOOKING_LEFT = 2}

Determines when to flip the [b]$Sprite2D[/b] child.

Looking

enum Looking{UP = 0, UP_RIGHT = 1, RIGHT = 2, DOWN_RIGHT = 3, DOWN = 4, DOWN_LEFT = 5, LEFT = 6, UP_LEFT = 7}

Determines the direction the character is facing

Property Descriptions

text_color

@export var text_color: Color = "(1, 1, 1, 1)"

The [Color] in which the dialogue lines of the character are rendered.

flips_when

@export var flips_when: PopochiuCharacter.FlipsWhen = 0

Depending on its value, the [b]$Sprite2D[/b] child will be flipped horizontally depending on which way the character is facing. If the value is [constant NONE], then the [b]$Sprite2D[/b] child won't be flipped.

voices

@export var voices: Array
  • Setter: @voices_setter

Array of [Dictionary] where each element has [code]{ emotion: String, variations: ArrayPopochiuAudioCue }[/code]. You can use this to define which [PopochiuAudioCue]s to play when the character speaks using a specific emotion.

follow_player

@export var follow_player: bool = false
  • Setter: @follow_player_setter

Whether the character should follow the player-controlled character (PC) when it moves through the room.

follow_player_offset

@export var follow_player_offset: Vector2 = "(20, 0)"

The offset between the player-controlled character (PC) and this character when it follows the former one.

avatars

@export var avatars: Array
  • Setter: @avatars_setter

Array of [Dictionary] where each element has [code]{ emotion: String, avatar: Texture }[/code]. You can use this to define which [Texture] to use as avatar for the character when it speaks using a specific emotion.

walk_speed

@export var walk_speed: float = 200

The speed at which the character will move in pixels per frame.

can_move

@export var can_move: bool = true

Whether the character can or not move.

ignore_walkable_areas

@export var ignore_walkable_areas: bool = false

Whether the character ignores or not walkable areas. If [code]true[/code], the character will move to any point in the room clicked by players without taking into account the walkable areas in it.

anti_glide_animation

@export var anti_glide_animation: bool = false

Whether the character will move only when the frame changes on its animation.

dialog_pos

@export var dialog_pos: Vector2

Used by the GUI to calculate where to render the dialogue lines said by the character when it speaks.

position_stored

var position_stored = null

The stored position of the character. Used when [member anti_glide_animation] is [code]true[/code].

last_room

var last_room: String = ""

Stores the [member PopochiuRoom.script_name] of the preiously visited [PopochiuRoom].

anim_suffix

var anim_suffix: String = ""

The suffix text to add to animation names.

is_moving

var is_moving: bool = false

Whether the character is or not moving through the room.

emotion

var emotion: String = ""

The current emotion used by the character.

on_scaling_region

var on_scaling_region: Dictionary

default_walk_speed

var default_walk_speed: int = 0

Stores the default walk speed defined in [member walk_speed]. Used by [PopochiuRoom] when scaling the character if it is inside a [PopochiuRegion] that modifies the scale.

default_scale

var default_scale: Vector2 = "(1, 1)"

Stores the default scale. Used by [PopochiuRoom] when scaling the character if it is inside a [PopochiuRegion] that modifies the scale.

Method Descriptions

queue_idle

func queue_idle() -> Callable

Puts the character in the idle state by playing its idle animation, then waits for [code]0.2[/code] seconds. If the characer has a [b]$Sprite2D[/b] child, it makes it flip based on the [member flips_when] value.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

idle

func idle() -> void

Puts the character in the idle state by playing its idle animation, then waits for [code]0.2[/code] seconds. If the characer has a [b]$Sprite2D[/b] child, it makes it flip based on the [member flips_when] value.

queue_walk

func queue_walk(target_pos: Vector2) -> Callable

Makes the character move to [param target_pos] and plays its walk animation. If the characer has a [b]$Sprite2D[/b] child, it makes it flip based on the [member flips_when] value.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk

func walk(target_pos: Vector2) -> void

Makes the character move to [param target_pos] and plays its walk animation. If the characer has a [b]$Sprite2D[/b] child, it makes it flip based on the [member flips_when] value.

take_turn

func take_turn(target_pos: Vector2)

queue_stop_walking

func queue_stop_walking() -> Callable

Makes the character stop moving and emits [signal stopped_walk].[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

stop_walking

func stop_walking() -> void

Makes the character stop moving and emits [signal stopped_walk].

queue_face_up

func queue_face_up() -> Callable

Makes the character to look up by setting [member _looking_dir] to [constant UP] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_up

func face_up() -> void

Makes the character to look up by setting [member _looking_dir] to [constant UP] and waits until [method idle] finishes.

queue_face_up_right

func queue_face_up_right() -> Callable

Makes the character to look up and right by setting [member _looking_dir] to [constant UP_RIGHT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_up_right

func face_up_right() -> void

Makes the character to look up and right by setting [member _looking_dir] to [constant UP_RIGHT] and waits until [method idle] finishes.

queue_face_right

func queue_face_right() -> Callable

Makes the character to look right by setting [member _looking_dir] to [constant RIGHT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_right

func face_right() -> void

Makes the character to look right by setting [member _looking_dir] to [constant RIGHT] and waits until [method idle] finishes.

queue_face_down_right

func queue_face_down_right() -> Callable

Makes the character to look down and right by setting [member _looking_dir] to [constant DOWN_RIGHT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_down_right

func face_down_right() -> void

Makes the character to look down and right by setting [member _looking_dir] to [constant DOWN_RIGHT] and waits until [method idle] finishes.

queue_face_down

func queue_face_down() -> Callable

Makes the character to look down by setting [member _looking_dir] to [constant DOWN] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_down

func face_down() -> void

Makes the character to look down by setting [member _looking_dir] to [constant DOWN] and waits until [method idle] finishes.

queue_face_down_left

func queue_face_down_left() -> Callable

Makes the character to look down and left by setting [member _looking_dir] to [constant DOWN_LEFT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_down_left

func face_down_left() -> void

Makes the character to look down and left by setting [member _looking_dir] to [constant DOWN_LEFT] and waits until [method idle] finishes.

queue_face_left

func queue_face_left() -> Callable

Makes the character to look left by setting [member _looking_dir] to [constant LEFT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_left

func face_left() -> void

Makes the character to look left by setting [member _looking_dir] to [constant LEFT] and waits until [method idle] finishes.

queue_face_up_left

func queue_face_up_left() -> Callable

Makes the character to look up and left by setting [member _looking_dir] to [constant UP_LEFT] and waits until [method idle] finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_up_left

func face_up_left() -> void

Makes the character to look up and left by setting [member _looking_dir] to [constant UP_LEFT] and waits until [method idle] finishes.

queue_face_clicked

func queue_face_clicked() -> Callable

Makes the character face in the direction of the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked].[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

face_clicked

func face_clicked() -> void

Makes the character face in the direction of the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked].

queue_say

func queue_say(dialog: String, emo: String = "") -> Callable

Calls [method _play_talk] and emits [signal character_spoke] sending itself as parameter, and the [param dialog] line to show on screen. You can specify the emotion to use with [param emo]. If an [AudioCue] is defined for the emotion, it is played. Once the talk animation finishes, the characters return to its idle state.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

say

func say(dialog: String, emo: String = "") -> void

Calls [method _play_talk] and emits [signal character_spoke] sending itself as parameter, and the [param dialog] line to show on screen. You can specify the emotion to use with [param emo]. If an [AudioCue] is defined for the emotion, it is played. Once the talk animation finishes, the characters return to its idle state.

queue_grab

func queue_grab() -> Callable

Calls [method _play_grab] and waits until the [signal grab_done] is emitted, then goes back to [method idle].[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

grab

func grab() -> void

Calls [method _play_grab] and waits until the [signal grab_done] is emitted, then goes back to [method idle].

hide_helpers

func hide_helpers() -> void

Calls [method PopochiuClickable.hide_helpers].

show_helpers

func show_helpers() -> void

Calls [method PopochiuClickable.show_helpers].

queue_walk_to

func queue_walk_to(pos: Vector2) -> Callable

Makes the character walk to [param pos].[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk_to

func walk_to(pos: Vector2) -> void

Makes the character walk to [param pos].

queue_walk_to_clicked

func queue_walk_to_clicked(offset: Vector2 = "(0, 0)") -> Callable

Makes the character walk to the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk_to_clicked

func walk_to_clicked(offset: Vector2 = "(0, 0)") -> void

Makes the character walk (NON-BLOCKING) to the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked]. You can set an [param offset] relative to the target position.

walk_to_clicked_blocking

func walk_to_clicked_blocking(offset: Vector2 = "(0, 0)") -> void

Makes the character walk (BLOCKING the GUI) to the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked]. You can set an [param offset] relative to the target position.

queue_walk_to_clicked_blocking

func queue_walk_to_clicked_blocking(offset: Vector2 = "(0, 0)") -> Callable

Makes the character walk (BLOCKING the GUI) to the last clicked [PopochiuClickable], which is stored in [member Popochiu.clicked]. You can set an [param offset] relative to the target position. [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

queue_walk_to_prop

func queue_walk_to_prop(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character walk to the PopochiuProp (in the current room) which [member PopochiuClickable.script_name] is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk_to_prop

func walk_to_prop(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character walk to the PopochiuProp (in the current room) which [member PopochiuClickable.script_name] is equal to [param id]. You can set an [param offset] relative to the target position.

queue_teleport_to_prop

func queue_teleport_to_prop(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character teleport (disappear at one location and instantly appear at another) to the PopochiuProp is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

teleport_to_prop

func teleport_to_prop(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character teleport (disappear at one location and instantly appear at another) to the PopochiuProp is equal to [param id]. You can set an [param offset] relative to the target position.

queue_walk_to_hotspot

func queue_walk_to_hotspot(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character walk to the PopochiuHotspot (in the current room) which [member PopochiuClickable.script_name] is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk_to_hotspot

func walk_to_hotspot(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character walk to the PopochiuHotspot (in the current room) which [member PopochiuClickable.script_name] is equal to [param id]. You can set an [param offset] relative to the target position.

queue_teleport_to_hotspot

func queue_teleport_to_hotspot(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character teleport (disappear at one location and instantly appear at another) to the PopochiuHotspot is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

teleport_to_hotspot

func teleport_to_hotspot(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character teleport (disappear at one location and instantly appear at another) to the PopochiuHotspot is equal to [param id]. You can set an [param offset] relative to the target position.

queue_walk_to_marker

func queue_walk_to_marker(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character walk to the [Marker2D] (in the current room) which [member Node.name] is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

walk_to_marker

func walk_to_marker(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character walk to the [Marker2D] (in the current room) which [member Node.name] is equal to [param id]. You can set an [param offset] relative to the target position.

queue_teleport_to_marker

func queue_teleport_to_marker(id: String, offset: Vector2 = "(0, 0)") -> Callable

Makes the character teleport (disappear at one location and instantly appear at another) to the [Marker2D] (in the current room) which [member Node.name] is equal to [param id]. You can set an [param offset] relative to the target position.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

teleport_to_marker

func teleport_to_marker(id: String, offset: Vector2 = "(0, 0)") -> void

Makes the character teleport (disappear at one location and instantly appear at another) to the [Marker2D] (in the current room) which [member Node.name] is equal to [param id]. You can set an [param offset] relative to the target position.

queue_set_emotion

func queue_set_emotion(new_emotion: String) -> Callable

Sets [member emotion] to [param new_emotion] when in a [method Popochiu.queue].

queue_ignore_walkable_areas

func queue_ignore_walkable_areas(new_value: bool) -> Callable

Sets [member ignore_walkable_areas] to [param new_value] when in a [method Popochiu.queue].

queue_play_animation

func queue_play_animation(animation_label: String, animation_fallback: String = "idle", blocking: bool = false) -> Callable

Plays the [param animation_label] animation. You can specify a fallback animation to play with [param animation_fallback] in case the former one doesn't exists.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

play_animation

func play_animation(animation_label: String, animation_fallback: String = "idle")

Plays the [param animation_label] animation. You can specify a fallback animation to play with [param animation_fallback] in case the former one doesn't exists.

queue_stop_animation

func queue_stop_animation()

Makes the animation that is currently playing to stop. Works only if it is looping and is not an idle animation. The animation stops when the current loop finishes.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

stop_animation

func stop_animation()

Makes the animation that is currently playing to stop. Works only if it is looping and is not an idle animation. The animation stops when the current loop finishes.

queue_halt_animation

func queue_halt_animation()

Immediately stops the animation that is currently playing by changing to the idle animation. [br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

halt_animation

func halt_animation()

Immediately stops the animation that is currently playing by changing to the idle animation.

queue_pause_animation

func queue_pause_animation()

Pauses the animation that is currently playing.[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

pause_animation

func pause_animation()

Pauses the animation that is currently playing.

queue_resume_animation

func queue_resume_animation()

Resumes the current animation (that was previously paused).[br][br] [i]This method is intended to be used inside a [method Popochiu.queue] of instructions.[/i]

resume_animation

func resume_animation()

Resumes the current animation (that was previously paused).

face_direction

func face_direction(destination: Vector2)

Makes the character look in the direction of [param destination]. The result is one of the values defined by [enum Looking].

get_avatar_for_emotion

func get_avatar_for_emotion(emo: String = "") -> Texture

Returns the [Texture] of the avatar defined for the [param emo] emotion. Returns [code]null[/code] if no avatar is found. If there is an avatar defined for the [code]""[/code] emotion, that one is returned by default.

get_dialog_pos

func get_dialog_pos() -> float

Returns the [code]y[/code] value of the dialog_pos [Vector2] that defines the position of the dialog lines said by the character when it talks.

update_position

func update_position() -> void

update_scale

func update_scale()

Updates the scale depending on the properties of the scaling region where it is located.

set_voices

func set_voices(value: Array) -> void

set_follow_player

func set_follow_player(value: bool) -> void

set_avatars

func set_avatars(value: Array) -> void

Signals

  • signal started_walk_to(character, start, end): Emitted when a [param character] starts moving from [param start] to [param end]. [PopochiuRoom] connects to this signal in order to make characters move inside them from one point to another.
  • signal stopped_walk(): Emitted when the character is forced to stop while walking.
  • signal move_ended(): Emitted when the character reaches the ending position when moving from one point to another.
  • signal grab_done(): Emitted when the animation to grab things has finished.