Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ControllableChar Abstract

All chars that can be controlled by human (Hero) or code/event procedures (NPC) have this class as the parent class. This class gives a lot of resources to control a char in the engine.

Hierarchy

Index

Constructors

Properties

Accessors

Methods

Constructors

  • new ControllableChar(game: Game, data: GoldenSun, key_name: string, enable_footsteps: boolean, walk_speed: number, dash_speed: number, climb_speed: number, is_npc: boolean, initial_x?: number, initial_y?: number, initial_action?: string, initial_animation?: string, storage_keys?: { action?: string; active?: string; animation?: string; position?: string }, active?: boolean, force_char_stop_in_event?: boolean, force_idle_action_in_event?: boolean): ControllableChar
  • Parameters

    • game: Game
    • data: GoldenSun
    • key_name: string
    • enable_footsteps: boolean
    • walk_speed: number
    • dash_speed: number
    • climb_speed: number
    • is_npc: boolean
    • Optional initial_x: number
    • Optional initial_y: number
    • Optional initial_action: string
    • Optional initial_animation: string
    • Optional storage_keys: { action?: string; active?: string; animation?: string; position?: string }
      • Optional action?: string
      • Optional active?: string
      • Optional animation?: string
      • Optional position?: string
    • Optional active: boolean
    • Optional force_char_stop_in_event: boolean
    • Optional force_idle_action_in_event: boolean

    Returns ControllableChar

Properties

_active: boolean
_active_filters: { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }

Type declaration

  • color_blend: boolean
  • colorize: boolean
  • flame: boolean
  • gray: boolean
  • hue: boolean
  • levels: boolean
  • mode7: boolean
  • outline: boolean
  • pixel_shift: boolean
  • tint: boolean
  • watery: boolean
_body_radius: number
_color_blend_filter: ColorBlend
_colorize_filter: Colorize
_current_action: string
_current_animation: string
_current_direction: number

The direction that the char is moving.

_current_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_default_scale: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_emoticon_sprite: Sprite
_extra_speed: number
_extra_speed_force: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_flame_filter: Flame
_footsteps: Footsteps
_force_diagonal_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_gray_filter: Gray
_hue_filter: Hue
_ice_slide_direction: number

The direction of the ice sliding movement that can be different of char direction.

_is_npc: boolean
_key_name: string
_levels_filter: Levels
_outline_filter: Outline
_pixel_shift_filter: PixelShift
_push_timer: Timer
_required_direction: number

The direction determined by the input.

_rotating: boolean
_rotating_elapsed: number
_rotating_frame_index: number
_rotating_interval: number
_shapes_collision_active: boolean
_sprite_info: SpriteBase
_sweat_drops: Sprite
_temp_speed: { x: number; y: number }

Type declaration

  • x: number
  • y: number
_tile_x_pos: number
_tile_y_pos: number
_tint_filter: Tint
_transition_direction: number

When changing directions, the char smoothly changes to the target direction. This var holds the intermediate directions.

_trying_to_push_direction: number

The direction that the char is trying to push an interactable object

_watery_filter: Watery
animation_change_callbacks: {}

Type declaration

  • [key: number]: (() => void)
      • (): void
      • Returns void

casting_aura_stop_function: ((reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>)

Type declaration

    • (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean): Promise<void>
    • The function used to stop this char casting aura.

      Parameters

      • Optional reset_casting_psy_flag: boolean
      • Optional reset_map_tint: boolean

      Returns Promise<void>

casting_psynergy: boolean

Whether this char is casting psynergy.

climb_speed: number
climbing: boolean

Whether this char is climbing.

climbing_rope: boolean

Whether this char is climbing a rope.

colliding_directions_mask: number

A mask that contains in which directions the hero is colliding. Example:

  • If the hero is colliding on left direction, which has 4 as value, then this variable will have this value: 00010000.
  • If the hero is colliding on right direction, which has 0 as value, then this variable will have this value: 00000001.
  • Colliding in both left and right direction: 00010001.
crop_texture: boolean

Whether the char is prone to have it's texture halved when going through forests.

dash_speed: number
dashing: boolean

Whether this char is dashing.

data: GoldenSun
enable_footsteps: boolean

Whether the char will let footprints in the ground.

force_char_stop_in_event: boolean

Forces this char to stop while in game event.

force_direction: boolean

Whether the char had its direction changed due to side collision.

force_idle_action_in_event: boolean

Forces char to assume idle action if it's forced to stop while in a game event.

game: Game
ice_sliding_active: boolean

Whether this char is under an ice sliding ground.

idle_climbing: boolean

Whether this char is idle during climbing state.

ignore_play: boolean

If true, animation play will be ignored.

jumping: boolean

Whether this char is jumping.

look_target: ControllableChar = null
misc_busy: boolean

Whether this char is busy by any misc. reason.

on_custom_psynergy_effect: boolean

Whether this char is under custom psynergy effect.

on_reveal: boolean

Whether this char is under Reveal psynergy effect.

on_stair: boolean

If true, it will assume that this char is walking over a stair. This will impact this char facing direction.

pushing: boolean

Whether this char is pushing an Interactable Object.

sand_mode: boolean

Whether this char is melted in sand.

shadow: Sprite

The shadow sprite object.

shadow_following: boolean

Whether the shadow is following or not this char.

sliding: boolean

Whether this char is cliff sliding.

sliding_on_ice: boolean

Whether this char is sliding/moving over an ice ground.

sprite: Sprite

The char main sprite object.

stop_by_colliding: boolean

Whether the char is idle/stopped due to collision.

storage_keys: { action?: string; active?: string; animation?: string; position?: string }

Type declaration

  • Optional action?: string
  • Optional active?: string
  • Optional animation?: string
  • Optional position?: string
teleporting: boolean

Whether this char is teleporting by the teleport TileEvent.

trying_to_push: boolean

Whether thic char is trying to push an Interactable Object.

walk_speed: number
walking_over_rope: boolean

Whether this char is walking over a rope.

DEFAULT_SHADOW_ANCHOR_X: 0.45 = 0.45
DEFAULT_SHADOW_ANCHOR_Y: 0.05 = 0.05
DEFAULT_SHADOW_KEYNAME: "shadow" = "shadow"
DEFAULT_SPRITE_ANCHOR_X: 0.5 = 0.5
DEFAULT_SPRITE_ANCHOR_Y: 0.8 = 0.8
DUST_ANIM_KEY: "spread" = "spread"
DUST_COUNT_GROUND_HIT: 7 = 7
DUST_KEY: "dust" = "dust"
DUST_RADIUS_GROUND_HIT: 18 = 18
INTERACTION_RANGE_ANGLE: number = numbers.degree75
SLIDE_ICE_SPEED: 95 = 95
SLIDE_ICE_WALK_FRAME_RATE: 20 = 20
TIME_PER_TILE: 40 = 40
WALK_OVER_ROPE_FRAME_RATE: 5 = 5
WALK_OVER_ROPE_SPEED: 30 = 30
default_anchor: { x: number; y: number } = ...

Type declaration

  • x: number
  • y: number

Accessors

  • get active(): boolean
  • get active_filters(): { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }
  • An object containing which filters are active in this char.

    Returns { color_blend: boolean; colorize: boolean; flame: boolean; gray: boolean; hue: boolean; levels: boolean; mode7: boolean; outline: boolean; pixel_shift: boolean; tint: boolean; watery: boolean }

    • color_blend: boolean
    • colorize: boolean
    • flame: boolean
    • gray: boolean
    • hue: boolean
    • levels: boolean
    • mode7: boolean
    • outline: boolean
    • pixel_shift: boolean
    • tint: boolean
    • watery: boolean
  • get body(): Body
  • get body_radius(): number
  • get collision_layer(): any
  • get color_blend_filter(): ColorBlend
  • The Phaser.Filter that controls the blend of colors of the texture of this char sprite.

    Returns ColorBlend

  • get colorize_filter(): Colorize
  • get current_action(): string
  • get current_animation(): string
  • get current_direction(): number
  • get current_speed(): { x: number; y: number }
  • This char current speed normalized vector. This pretty much indicates the char direction.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get extra_speed(): number
  • get extra_speed_force(): { x: number; y: number }
  • The extra char speed that might be applied to current speed even if it's idle.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get flame_filter(): Flame
  • get force_diagonal_speed(): { x: number; y: number }
  • This char speed according to the collision slope.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get gray_filter(): Gray
  • get height(): number
  • get hue_filter(): Hue
  • get ice_slide_direction(): number
  • The direction in which this char is sliding in the ice. It's not necessarily the direction that this char is facing.

    Returns number

  • get is_interactable_object(): boolean
  • get is_npc(): boolean
  • get key_name(): string
  • get levels_filter(): Levels
  • get outline_filter(): Outline
  • get pixel_shift_filter(): PixelShift
  • get push_timer(): Timer
  • get required_direction(): number
  • get shapes_collision_active(): boolean
  • get temp_speed(): { x: number; y: number }
  • This char pre-caculated speed. It might change due to collision.

    Returns { x: number; y: number }

    • x: number
    • y: number
  • get tile_pos(): { x: number; y: number }
  • get tile_x_pos(): number
  • get tile_y_pos(): number
  • get tint_filter(): Tint
  • get transition_direction(): number
  • When changing direction, the char doesn't face immediately the requested direction. This property holds the transion directions till it reaches the requested direction.

    Returns number

  • get trying_to_push_direction(): number
  • get watery_filter(): Watery
  • get width(): number
  • get x(): number
  • set x(x: number): void
  • get y(): number
  • set y(y: number): void

Methods

  • add_animation_callback(callback: (() => void)): number
  • Adds a callback for this char that will be called when this char animation changes.

    Parameters

    • callback: (() => void)

      the callback that will be called.

        • (): void
        • Returns void

    Returns number

    returns the key to track this callback, so you can identify it later to remove.

  • apply_speed(): void
  • blink(count: number, interval: number, options?: { color?: { b: number; g: number; r: number }; keep_filter?: boolean; outline_blink?: boolean; transparent_outline?: boolean }): Promise<void>
  • Blinks this char by tintint and untinting it or outlining it.

    Parameters

    • count: number

      how many times this char will blink.

    • interval: number

      the time interval between each blink.

    • Optional options: { color?: { b: number; g: number; r: number }; keep_filter?: boolean; outline_blink?: boolean; transparent_outline?: boolean }

      some options.

      • Optional color?: { b: number; g: number; r: number }

        The color to tint/outline the char.

        • b: number

          The blue color component to tint. 0 to 1. Default 1.

        • g: number

          The green color component to tint. 0 to 1. Default 1.

        • r: number

          The red color component to tint. 0 to 1. Default 1.

      • Optional keep_filter?: boolean

        if true, will keep the color filter on blink finish.

      • Optional outline_blink?: boolean

        If true, the char will be outlined instead of tinted. Default is false.

      • Optional transparent_outline?: boolean

        If 'outline_blink' is true, whether the char will be transparent or not when outlined. Default is true.

    Returns Promise<void>

  • calculate_speed(): void
  • check_footsteps(): void
  • check_half_crop_tile(force?: boolean): void
  • Checks whether is necessary to set or unset the cropping mask.

    Parameters

    • force: boolean = false

      if true, forces the setting/unsetting action.

    Returns void

  • check_interactable_objects(contacts: ContactEquation[]): void
  • Checks if this char is colliding with any interactable object and fire any possible interaction with it.

    Parameters

    • contacts: ContactEquation[]

    Returns void

  • check_sand_quit(contacts: ContactEquation[]): boolean
  • Checks if this char will quit sand mode by colliding with a tile that has quit_sand property true.

    Parameters

    • contacts: ContactEquation[]

      p2 contact equation array.

    Returns boolean

    returns true if it exited sand mode.

  • choose_action_based_on_char_state(check_on_event?: boolean): void
  • Chooses this char action based on its states like climbing, walk, dash etc.

    Parameters

    • check_on_event: boolean = false

      if true, will check whether the game has any event running.

    Returns void

  • choose_direction_by_speed(): void
  • create_half_crop_mask(): void
  • Creates an cropping mask for the lower half of the char when it's in a tile that has the half_crop property set to true.

    Returns void

  • destroy_emoticon(): void
  • face_direction(direction: number, time_between_frames?: number): Promise<void>
  • Makes this char to face a given direction.

    Parameters

    • direction: number

      the direction to be faced.

    • time_between_frames: number = 40

      time interval between transition directions.

    Returns Promise<void>

  • fall(options: { dest_collision_layer?: number; ground_hit_animation?: boolean; show_exclamation_emoticon?: boolean; splash_sweat_drops?: boolean; teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }; walking_in_the_air?: boolean; y_destination_position: number; on_fall_finish_callback?: any }): Promise<void>
  • Make the char to fall to a given destination.

    Parameters

    • options: { dest_collision_layer?: number; ground_hit_animation?: boolean; show_exclamation_emoticon?: boolean; splash_sweat_drops?: boolean; teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }; walking_in_the_air?: boolean; y_destination_position: number; on_fall_finish_callback?: any }

      fall options object.

      • Optional dest_collision_layer?: number

        The destination collision layer index.

      • Optional ground_hit_animation?: boolean

        Whether the char will perform a ground hit animation.

      • Optional show_exclamation_emoticon?: boolean

        Whether an exclamation emoticon will appear over the char before falling.

      • Optional splash_sweat_drops?: boolean

        The char will splash sweat drops before falling.

      • Optional teleport?: { dest_collision_layer: number; destination: string; destination_position: { x: number; y: number }; diminish_on_transition?: boolean; origin_position?: { x: number; y: number }; send_to_front_on_teleport?: boolean; on_before_teleport?: any }

        Teleport info. If passed, the char will teleport to another map while falling.

        • dest_collision_layer: number

          The destination collision layer index in the dest map.

        • destination: string

          The teleport map key name destination.

        • destination_position: { x: number; y: number }

          The destination position.

          • x: number

            The x tile position.

          • y: number

            The y tile position.

        • Optional diminish_on_transition?: boolean

          If true, the char will diminish instead of fall before teleport.

        • Optional origin_position?: { x: number; y: number }

          The origin position that the char will be just after the teleport.

          • x: number

            The x tile position.

          • y: number

            The y tile position.

        • Optional send_to_front_on_teleport?: boolean

          If true, the char sprite will be brought to the top on z-index while falling.

        • on_before_teleport?:function
          • on_before_teleport(): void
      • Optional walking_in_the_air?: boolean

        Whether the char will performa a walking in the air animation before falling.

      • y_destination_position: number

        The final y-tile position that the char will reach after falling.

      • on_fall_finish_callback?:function
        • on_fall_finish_callback(): void

    Returns Promise<void>

  • get_move_callback(dest: { x: number; y: number }, on_position_reach_callback: (() => void), minimal_distance?: number): (() => void)
  • Gets the update callback that need to be fired under a loop in order to move this char to a specific position.

    Parameters

    • dest: { x: number; y: number }

      the desitiona position object.

      • x: number
      • y: number
    • on_position_reach_callback: (() => void)

      the callback that will be called when this char reaches the position.

        • (): void
        • Returns void

    • minimal_distance: number = 3

      the minimal distance to be regarded to when check whether this char is close enough to the destination.

    Returns (() => void)

    return the update callback to keep this char moving and checking whether it should stop.

      • (): void
      • Returns void

  • ground_hit_dust_animation(on_animation_end: (() => void)): void
  • Plays an animation for the char hitting the ground when falling.

    Parameters

    • on_animation_end: (() => void)

      calback to be called on animation end.

        • (): void
        • Returns void

    Returns void

  • in_action(allow_climbing?: boolean): boolean
  • Returns whether this char is in action;

    Parameters

    • allow_climbing: boolean = false

      if true, climbing won't be considered.

    Returns boolean

    Returns whether this char is in action.

  • in_movement(walk_dash_only?: boolean): boolean
  • Checks whether this char is in movement.

    Parameters

    • walk_dash_only: boolean = false

      if true, will check only dash and walk.

    Returns boolean

    returns true if in movement.

  • increase_extra_speed(delta_value: number): void
  • increase_forced_extra_speed(delta_value: { x?: number; y?: number }): void
  • Increments the char forced extra speed value.

    Parameters

    • delta_value: { x?: number; y?: number }

      the x and/or y speed variation object.

      • Optional x?: number
      • Optional y?: number

    Returns void

  • Checks whether this char is interacting with another one from the back.

    Parameters

    Returns boolean

    returns whether this char is interacting from the back or not.

  • is_close(target_char: NPC): number
  • Returns if this char is enough close to a target char.

    Parameters

    • target_char: NPC

      The target char.

    Returns number

    If it's close enough, returns the distance, else returns null.

  • jump(options: { bounce?: boolean; dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }; dont_play_jump_animation?: boolean; duration?: number; jump_direction?: directions; jump_height?: number; keep_shadow_hidden?: boolean; sfx_key?: string; time_on_finish?: number }): Promise<void>
  • Makes this char to jump vertically or to a specific destination.

    Parameters

    • options: { bounce?: boolean; dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }; dont_play_jump_animation?: boolean; duration?: number; jump_direction?: directions; jump_height?: number; keep_shadow_hidden?: boolean; sfx_key?: string; time_on_finish?: number }
      • Optional bounce?: boolean

        Whether the char will bounce on jump finish. Only for vertical jumps.

      • Optional dest?: { distance?: number; distance_multiplier?: number; tile_x?: number; tile_y?: number; x?: number; y?: number }

        If this object is set, the char will perform a jump towards a given direction.

        • Optional distance?: number

          The jump distance that this char will perform. If not given, this char will jump into the center of the destination. This option is not valid if it's a diagonal direction jumping.

        • Optional distance_multiplier?: number

          The distance multiplier that will be applied to the final jump distance.

        • Optional tile_x?: number

          The x tile position destination. If position in px is defined, this one won't be used.

        • Optional tile_y?: number

          The y tile position destination. If position in px is defined, this one won't be used.

        • Optional x?: number

          The x position destination in px. This position has preference over tile position.

        • Optional y?: number

          The y position destination in px. This position has preference over tile position.

      • Optional dont_play_jump_animation?: boolean

        If true, char jump animation won't be played.

      • Optional duration?: number

        The duration of the jump in ms.

      • Optional jump_direction?: directions

        The direction that the char is going to be while jumping.

      • Optional jump_height?: number

        The height of the jump in px. This option is not valid if it's a diagonal direction jumping.

      • Optional keep_shadow_hidden?: boolean

        Whether the char shadow will remain hidden after jump.

      • Optional sfx_key?: string

        The sound effect to play while jumping.

      • Optional time_on_finish?: number

        A time to wait on jump finish in ms.

    Returns Promise<void>

  • look_to_target(): void
  • manage_filter(filter: Filter, set: boolean): void
  • Sets or unsets a Phaser.Filter in this char.

    Parameters

    • filter: Filter

      the filter you want to set.

    • set: boolean

      whether it's to set or unset the filter.

    Returns void

  • play(action?: string, animation?: string, start?: boolean, frame_rate?: number, loop?: boolean, reset_before_start?: boolean, reversed?: boolean): Animation
  • Plays an animation of this char.

    Parameters

    • Optional action: string

      the action that this char is going to doing.

    • Optional animation: string

      an specific animation of the given action that this char is going to be executing.

    • start: boolean = true

      whether you want the animation to start. Otherwise it will be stopped.

    • Optional frame_rate: number

      a custom frame rate value.

    • Optional loop: boolean

      whether the animation will be looping.

    • Optional reset_before_start: boolean

      whether the animation will reset before start.

    • Optional reversed: boolean

      whether the animation will be played on reverse sense.

    Returns Animation

    Returns the resulting Phaser.Animation object.

  • play_current_action(check_on_event?: boolean, force_squat?: boolean): void
  • Plays the current action of this char.

    Parameters

    • check_on_event: boolean = false

      if true, will check whether the game has any event running.

    • force_squat: boolean = false

    Returns void

  • remove_animation_callback(key: number): boolean
  • Removes a callback added by add_animation_callback method.

    Parameters

    • key: number

      the callback unique key.

    Returns boolean

    returns true if the callback was removed successfully.

  • reset_anchor(property?: "x" | "y"): void
  • Reset anchor values to default.

    Parameters

    • Optional property: "x" | "y"

      define whether it is y or x anchor property.

    Returns void

  • reset_scale(): void
  • rotate(): void
  • set_collision_layer(layer: number): void
  • Changes the collision layer of this char.

    Parameters

    • layer: number

      the collision layer index.

    Returns void

  • set_direction(direction?: directions, force_change?: boolean, transition_also?: boolean): void
  • Changes the char current direction to the given direction.

    Parameters

    • Optional direction: directions

      the direction to change.

    • force_change: boolean = false

      plays this new direction.

    • transition_also: boolean = true

      also change the transition direction.

    Returns void

  • set_frame(animation: string | directions, frame_index?: number, action?: string): void
  • Set a specific frame for this char.

    Parameters

    • animation: string | directions

      the animation or direction of the target frame.

    • frame_index: number = 0

      the frame index.

    • Optional action: string

      the action of the target frame.

    Returns void

  • set_half_crop_mask(crop: boolean, force?: boolean): void
  • Sets or unsets the the cropping mask.

    Parameters

    • crop: boolean

      if true, sets the cropping mask.

    • force: boolean = false

      forces the setting/unsetting action.

    Returns void

  • set_hue(activate: boolean, angle?: number): void
  • Sets or unsets the hue filter in this char.

    Parameters

    • activate: boolean

      whether you want to activate the hue filter or not.

    • Optional angle: number

      the hue angle.

    Returns void

  • set_ice_slide_direction(direction: directions): void
  • Activate or deactivate target looking.

    Parameters

    • active: boolean

      Whether you want to activate or deactivate.

    • Optional target: ControllableChar

      The target char whether this char is going keep looking.

    Returns void

  • set_outline(activate: boolean, options?: { b?: number; g?: number; keep_transparent?: boolean; r?: number }): void
  • Sets or unsets an outline in this char. You can also use this function to update options. Otherwise, use ControllableChar.outline_filter directly.

    Parameters

    • activate: boolean

      whether you want to activate the outline or not.

    • Optional options: { b?: number; g?: number; keep_transparent?: boolean; r?: number }

      some options.

      • Optional b?: number

        The blue color component of the outline. 0 to 1. Default 1.

      • Optional g?: number

        The green color component of the outline. 0 to 1. Default 1.

      • Optional keep_transparent?: boolean

        If this property is true, the char will be transparent excepting the outline. Default false.

      • Optional r?: number

        The red color component of the outline. 0 to 1. Default 1.

    Returns void

  • set_position(position: { x?: number; y?: number }, update_shadow?: boolean): void
  • Sets this char position.

    Parameters

    • position: { x?: number; y?: number }

      the x/y positions in px.

      • Optional x?: number
      • Optional y?: number
    • update_shadow: boolean = true

    Returns void

  • set_push_timer(callback: (() => void), delay?: number): void
  • Sets the push timer for this char. This timer is used to start the object pushing. The char must wait for this timer before pushing.

    Parameters

    • callback: (() => void)

      the timer callback.

        • (): void
        • Returns void

    • delay: number = Phaser.Timer.QUARTER

      the initial delay.

    Returns void

  • set_rotation(rotate: boolean, interframe_interval?: number, frame_index?: number): void
  • Activates or deactivates this char rotation on z-axis.

    Parameters

    • rotate: boolean

      if true, activates the rotation.

    • interframe_interval: number = -1

      frame change rate interval in ms. -1 to change every frame.

    • Optional frame_index: number

      optionally specifies a frame index to be in when rotating.

    Returns void

  • set_shadow(group: Group, options?: { is_world_map?: boolean; key_name?: string; shadow_anchor_x?: number; shadow_anchor_y?: number }): void
  • Initialize the shadow sprite of this char.

    Parameters

    • group: Group

      the group where the shadow sprite is going to be inserted.

    • Optional options: { is_world_map?: boolean; key_name?: string; shadow_anchor_x?: number; shadow_anchor_y?: number }

      options to be set like anchor values and whether it's a world map.

      • Optional is_world_map?: boolean
      • Optional key_name?: string
      • Optional shadow_anchor_x?: number
      • Optional shadow_anchor_y?: number

    Returns void

  • set_speed(x_speed: number, y_speed: number, apply_speed?: boolean): void
  • Sets some speed values.

    Parameters

    • x_speed: number

      the x speed value.

    • y_speed: number

      the y speed value.

    • apply_speed: boolean = true

      if true, the given speed will be applied.

    Returns void

  • set_sprite(group: Group, sprite_info: SpriteBase, layer: number, map: Map, anchor_x?: number, anchor_y?: number, scale_x?: number, scale_y?: number, initial_x_px?: number, initial_y_px?: number): void
  • Initializes the char sprite.

    Parameters

    • group: Group

      the group that this is char is going to be inserted.

    • sprite_info: SpriteBase

      the frames and animations information of this char.

    • layer: number

      the collision layer that this char is.

    • map: Map

      the map where this char is going to be in.

    • Optional anchor_x: number

      optional x anchor value of the sprite.

    • Optional anchor_y: number

      optional y anchor value of the sprite.

    • Optional scale_x: number

      optional x scale value of the sprite.

    • Optional scale_y: number

      optional y scale value of the sprite.

    • Optional initial_x_px: number
    • Optional initial_y_px: number

    Returns void

  • set_temporary_speed(x_speed?: number, y_speed?: number): void
  • Sets some temporary speed values. These temporary values are set before collision analysis and may suffer changes on it. After collision analysis, they are indeed applied to actual speed values.

    Parameters

    • Optional x_speed: number

      the x speed value.

    • Optional y_speed: number

      the y speed value.

    Returns void

  • set_trying_to_push_direction(direction: directions): void
  • shake(options?: { max_scale_mult?: number; repeat_period?: number; repeats_number?: number; side_shake?: boolean }): Promise<void>
  • Shakes this char by changing its scale.

    Parameters

    • Optional options: { max_scale_mult?: number; repeat_period?: number; repeats_number?: number; side_shake?: boolean }
      • Optional max_scale_mult?: number

        Max scale multiplier

      • Optional repeat_period?: number

        Duration of each shake

      • Optional repeats_number?: number

        How many times the char should shake

      • Optional side_shake?: boolean

        If true, the char will shake horizontally

    Returns Promise<void>

  • show_emoticon(emoticon_key: string, options?: { duration?: number; location?: { x?: number; y?: number }; sound_effect?: string }): Promise<Sprite>
  • Shows an emoticon above this char.

    Parameters

    • emoticon_key: string

      The emoticon key name.

    • Optional options: { duration?: number; location?: { x?: number; y?: number }; sound_effect?: string }

      Some custom options.

      • Optional duration?: number

        The duration that this emoticon is going to be shown in ms. -1 for forever.

      • Optional location?: { x?: number; y?: number }

        A custom location for the emoticon.

        • Optional x?: number
        • Optional y?: number
      • Optional sound_effect?: string

        Sound effect key to be played.

    Returns Promise<Sprite>

    returns the emoticon sprite.

  • splash_sweat_drops(times?: number): Promise<void>
  • Splashes sweat drops from this char. The drops will follow this char pos.

    Parameters

    • times: number = 2

      how many times the sweat drops will splash.

    Returns Promise<void>

  • stop_animation(reset_frame?: boolean): void
  • Stops the current animation of this char.

    Parameters

    • reset_frame: boolean = true

      Resets the current animation to the first frame.

    Returns void

  • stop_char(change_sprite?: boolean): void
  • Stops the char movement.

    Parameters

    • change_sprite: boolean = true

      if true, sets idle animation.

    Returns void

  • tile_able_to_show_footprint(): boolean
  • Checks whether the current tile forbids this char to don't show footprints.

    Returns boolean

    whether the footprint will be shown or not.

  • toggle_active(active: boolean): void
  • toggle_collision(enable: boolean): boolean
  • Sets whether the collision body of this char is enable or not.

    Parameters

    • enable: boolean

      if true, activates the collision.

    Returns boolean

  • unset_push_timer(): void
  • update_half_crop(force?: boolean): void
  • The half cropping mask update function.

    Parameters

    • force: boolean = false

      if true, forces the mask appliance.

    Returns void

  • update_movement(ignore_collide_action_change?: boolean): void
  • Updates the char movement.

    Parameters

    • ignore_collide_action_change: boolean = false

      if true, ignores the collision impact on movement

    Returns void

  • update_on_event(): void
  • update_shadow(): void
  • update_sweat_drops_position(): void
  • update_tile_position(): void

Generated using TypeDoc