Options
All
  • Public
  • Public/Protected
  • All
Menu

A basic window template used in most menus. Creates the background and borders. Supports the addition of sprites, texts, and custom groups. Supports pagination indication, text manipulation and also icons positioning.

Hierarchy

  • Window

Index

Constructors

  • new Window(game: Game, x: number, y: number, width: number, height: number, color?: number, font_color?: number, mind_read_window?: boolean): Window
  • Parameters

    • game: Game
    • x: number
    • y: number
    • width: number
    • height: number
    • Optional color: number
    • Optional font_color: number
    • mind_read_window: boolean = false

    Returns Window

Properties

_color: number
_font_color: number
_group: Group
_height: number
_mind_read_borders: { left: BitmapData; right: BitmapData }

Type declaration

  • left: BitmapData
  • right: BitmapData
_mind_read_time: number
_mind_read_window: boolean
_open: boolean
_page_indicator: PageIndicator
_text_tween: Tween
_width: number
_x: number
_y: number
bg_graphics: Graphics
border_graphics: Graphics
canvas_update_set: boolean
close_callback: (() => void)

Type declaration

    • (): void
    • Returns void

extra_sprites: (Sprite | Group | Graphics | BitmapText)[]
game: Game
internal_groups: {}

Type declaration

  • [key: string]: Phaser.Group
separators_graphics: Graphics
BG_SHIFT: 2 = 2
DEFAULT_WINDOW_COLOR: 24704 = 0x006080
ITEM_OBJ: { EQUIPPED_X: number; EQUIPPED_Y: number; QUANTITY_END_X: number; QUANTITY_Y: number } = ...

Type declaration

  • EQUIPPED_X: number
  • EQUIPPED_Y: number
  • QUANTITY_END_X: number
  • QUANTITY_Y: number
MIND_READ_AMPLITUDE: 4 = 4
MIND_READ_CORNER_RADIUS: 12 = 12
MIND_READ_FONT_COLOR: 248 = 0x0000f8
MIND_READ_PERIOD: 20 = 20
MIND_READ_WAVE_SPEED: 0.005 = 0.005
MIND_READ_WINDOW_COLOR: 16777215 = 0xffffff
TRANSITION_TIME: number = ...

Accessors

  • get color(): number
  • get font_color(): number
  • get group(): Group
  • get height(): number
  • get open(): boolean
  • get real_x(): number
  • get real_y(): number
  • get text_tween(): Tween
  • get width(): number
  • get x(): number
  • get y(): number

Methods

  • add_sprite_to_window_group(sprite: Sprite | Group | Graphics | BitmapText): void
  • Adds a sprite to the main group of this window.

    Parameters

    • sprite: Sprite | Group | Graphics | BitmapText

      The sprite to be added.

    Returns void

  • add_to_internal_group(key: string, sprite: Sprite | Group | Graphics | BitmapText): boolean
  • Adds a sprite to an internal group.

    Parameters

    • key: string

      The internal group key.

    • sprite: Sprite | Group | Graphics | BitmapText

      The sprite to be added.

    Returns boolean

    True if the sprite was successfully added, false otherwise.

  • bring_border_to_top(): void
  • Brings the border graphics to top position in window group.

    Returns void

  • clean_text_tween(): void
  • If text tween was set when using Window.tween_text_horizontally, this function can stop and destroy it.

    Returns void

  • clear_separators(): void
  • close(callback?: (() => void), animate?: boolean): void
  • Closes this window.

    Parameters

    • Optional callback: (() => void)

      Callback function.

        • (): void
        • Returns void

    • animate: boolean = true

      Plays a fading animation if true.

    Returns void

  • create_at_group(x: number, y: number, key: string, options?: { color?: number; frame?: string; internal_group_key?: string }): Sprite
  • Creates a new sprite in the main group of this window.

    Parameters

    • x: number

      the x position of the sprite.

    • y: number

      the y position of the sprite.

    • key: string

      the sprite key name.

    • Optional options: { color?: number; frame?: string; internal_group_key?: string }

      some optional options.

      • Optional color?: number

        The color of the sprite (tint property).

      • Optional frame?: string

        The sprite frame name.

      • Optional internal_group_key?: string

        The internal group key in the case the sprite should be added in an internal group.

    Returns Sprite

    Returns the added sprite.

  • define_internal_group(key: string, position?: { x?: number; y?: number }): Group
  • Creates an internal group. A internal group is a Phaser.Group that can be retrieved by a key and is used to attach other sprites to this window.

    Parameters

    • key: string

      The group's key.

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

      The position object of the internal group.

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

    Returns Group

    Returns the internal group.

  • destroy(animate: boolean, destroy_callback?: (() => void)): void
  • Destroys this window.

    Parameters

    • animate: boolean

      Plays a fading animation if true.

    • Optional destroy_callback: (() => void)

      Callback function.

        • (): void
        • Returns void

    Returns void

  • destroy_all_internal_groups(): void
  • destroy_internal_group(key: string): void
  • Destroys an internal group and its elements.

    Parameters

    • key: string

      The internal group key.

    Returns void

  • destroy_text_obj(text_obj: TextObj): void
  • Destroys a given text object.

    Parameters

    • text_obj: TextObj

      The text obj. to be destroyed.

    Returns void

  • draw_background(): void
  • Creates the window background. Fills the window's space with the window color.

    Returns void

  • draw_borders(): void
  • Draws the window borders. Lines are drawn to create the borders, including corners. Colors used: 0xFFFFFF = White, 0xA5A5A5 = Gray (Lighter), 0x525252 = Gray (Darker), 0x111111 = Black.

    Returns void

  • draw_separator(x_0: number, y_0: number, x_1: number, y_1: number, vertical?: boolean): void
  • Draws separator graphics in the window. These are created by changing the brightness of the background.

    Parameters

    • x_0: number

      Initial x line separator position.

    • y_0: number

      Initial y line separator position.

    • x_1: number

      Final x line separator position.

    • y_1: number

      Final y line separator position.

    • vertical: boolean = true

      if true, the separator is a vertical line, otherwise horizontal.

    Returns void

  • get_internal_group(key: string): Group
  • Returns an internal group.

    Parameters

    • key: string

      The internal group key.

    Returns Group

    Returns an internal group.

  • init_mind_read_borders(): void
  • Initializes the waving borders of the mind read window.

    Returns void

  • make_item_obj(key_name: string, pos?: { x: number; y: number }, params?: { bg?: boolean; broken?: boolean; center?: boolean; equipped?: boolean; internal_group: string; quantity?: number }): ItemObj
  • Creates in this window an item object. An item object is a internal window group that contains the item icon, the item quantity, the graphics for a broken item, the equip graphics indication and the item background graphics (like in shops).

    Parameters

    • key_name: string

      the item key name.

    • Optional pos: { x: number; y: number }

      the item object position.

      • x: number
      • y: number
    • Optional params: { bg?: boolean; broken?: boolean; center?: boolean; equipped?: boolean; internal_group: string; quantity?: number }

      some optional parameters.

      • Optional bg?: boolean

        Whether this item obj. has a background graphics (like in shops).

      • Optional broken?: boolean

        Whether this item obj. should show the broken item graphics.

      • Optional center?: boolean

        Whether the icon positioning should be relative to item obj. center.

      • Optional equipped?: boolean

        Whether this item obj. should show the equipped indication graphics.

      • internal_group: string

        The window internal group key. If using params arg, this key must be passed.

      • Optional quantity?: number

        Shows the quatity indicator graphics if the given quantity is bigger than 1.

    Returns ItemObj

    returns the item object.

  • move_item_obj(item_obj: ItemObj, new_pos: { x: number; y: number }): void
  • Moves an item object in the window.

    Parameters

    • item_obj: ItemObj

      The item object.

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

      The coordinates of the new position.

      • x: number
      • y: number

    Returns void

  • remove_from_this_window(sprite?: Sprite | Group | Graphics | BitmapText, destroy?: boolean, exception_list?: (Sprite | Group | Graphics | BitmapText)[]): void
  • Removes a sprite from the main group of this window.

    Parameters

    • Optional sprite: Sprite | Group | Graphics | BitmapText

      The sprite to be removed.

    • destroy: boolean = true

      If true, the sprite is destroyed.

    • Optional exception_list: (Sprite | Group | Graphics | BitmapText)[]

      list of sprites that won't be destroyed.

    Returns void

  • reset_text_position(text_obj: TextObj, italic?: boolean): void
  • Resets a text object to default position.

    Parameters

    • text_obj: TextObj

      The text object.

    • italic: boolean = false

      Whether the text object is in italic.

    Returns void

  • send_to_front(): void
  • set_canvas_update(): void
  • Will update this window position in respect to canvas instead of camera.

    Returns void

  • set_dialog_text(lines: string[], options?: { animate?: boolean; colors?: number | number[][]; italic?: boolean; padding_x?: number; padding_y?: number; pauses?: {}[]; space_between_lines?: number; word_callback?: any }): Promise<void>
  • Sets a text in a dialog manner in this window.

    Parameters

    • lines: string[]

      The text lines (array of string).

    • Optional options: { animate?: boolean; colors?: number | number[][]; italic?: boolean; padding_x?: number; padding_y?: number; pauses?: {}[]; space_between_lines?: number; word_callback?: any }

      some optional parameters.

      • Optional animate?: boolean

        Whether the text is displayed in a animated manner.

      • Optional colors?: number | number[][]

        The font color. Can be an array of colors the indicates for each letter.

      • Optional italic?: boolean

        Whether the text is in italic.

      • Optional padding_x?: number

        The x internal padding text position.

      • Optional padding_y?: number

        The y internal padding text position.

      • Optional pauses?: {}[]

        Specific points to pause/delay the dialog. Each array item represents a line. An item is an object containing the follow key:value -> line_letter_index:duration_ms. The duration is in ms.

      • Optional space_between_lines?: number

        A custom value for the space between text lines.

      • word_callback?:function
        • word_callback(word?: string, current_text?: string, word_index?: number): void
        • A callback the is called whenever a word is displayed in the window when animate is true.

          Parameters

          • Optional word: string
          • Optional current_text: string
          • Optional word_index: number

          Returns void

    Returns Promise<void>

    Returns a promise that is resolved on animation finish.

  • set_lines_of_text(lines: string[], options?: { padding_x?: number; padding_y?: number; space_between_lines?: number; update_size?: boolean } & { color?: number; internal_group_key?: string; is_center_pos?: boolean; italic?: boolean; right_align?: boolean; with_bg?: boolean }): TextObj[]
  • Sets in this window lines of text.

    Parameters

    • lines: string[]

      An array of strings containing the texts.

    • Optional options: { padding_x?: number; padding_y?: number; space_between_lines?: number; update_size?: boolean } & { color?: number; internal_group_key?: string; is_center_pos?: boolean; italic?: boolean; right_align?: boolean; with_bg?: boolean }

      Some optional parameters.

    Returns TextObj[]

    Returns an array of TextObjs that were inserted.

  • set_text_in_position(text: string, x_pos?: number, y_pos?: number, options?: { color?: number; internal_group_key?: string; is_center_pos?: boolean; italic?: boolean; right_align?: boolean; with_bg?: boolean }): TextObj
  • Creates a sprite to represent a text at a given location.

    Parameters

    • text: string

      The text to display.

    • Optional x_pos: number

      The desired x postion. If not passed, default value will be assumed.

    • Optional y_pos: number

      The desired y postion. If not passed, default value will be assumed.

    • Optional options: { color?: number; internal_group_key?: string; is_center_pos?: boolean; italic?: boolean; right_align?: boolean; with_bg?: boolean }

      Some optional parameters.

      • Optional color?: number

        The text's desired color

      • Optional internal_group_key?: string

        If this exists, the text will belong to that group.

      • Optional is_center_pos?: boolean

        If true, the text will be centered.

      • Optional italic?: boolean

        If true, the text will be italic.

      • Optional right_align?: boolean

        If true, the text will be right-aligned.

      • Optional with_bg?: boolean

        If true, gives the text a background shape.

    Returns TextObj

    Returns the resulting text object.

  • set_text_obj_visibility(visible: boolean, text_obj: TextObj): void
  • Sets the visibility of a given text object.

    Parameters

    • visible: boolean

      The visibility state.

    • text_obj: TextObj

      The text obj.

    Returns void

  • show(show_callback?: (() => void), animate?: boolean, close_callback?: (() => void)): void
  • Displays this window.

    Parameters

    • Optional show_callback: (() => void)

      on window show callback.

        • (): void
        • Returns void

    • animate: boolean = true

      If true, plays an opening animation.

    • Optional close_callback: (() => void)

      on window close callback.

        • (): void
        • Returns void

    Returns void

  • tween_text_horizontally(text_obj: TextObj, x: number, duration?: number): Tween
  • Tweens the text horizontally back and forth. Use this when you expect the text to be bigger than the window.

    Parameters

    • text_obj: TextObj

      The text object to be tweened.

    • x: number

      the x postition destination.

    • duration: number = 3000

      The tween duration.

    Returns Tween

    Return the tween object.

  • update(): void
  • update_mind_read_borders(): void
  • Updates the waving borders of the mind read window.

    Returns void

  • update_position(new_position: { x?: number; y?: number }, relative_to_camera_pos?: boolean): void
  • Changes the window's position.

    Parameters

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

      The position's parameters.

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

      If true, moves the window by the x and y offset values.

    Returns void

  • update_size(new_size: { height?: number; width?: number }): void
  • Changes the window's size and redraws it.

    Parameters

    • new_size: { height?: number; width?: number }

      The new width and height parameters.

      • Optional height?: number
      • Optional width?: number

    Returns void

  • update_text(new_text: string, text_obj: TextObj, color?: number): void
  • Changes the text of a text object.

    Parameters

    • new_text: string

      The new text to show.

    • text_obj: TextObj

      The text object to be updated.

    • Optional color: number

    Returns void

  • update_text_color(color: number, text_obj: TextObj): void
  • Changes the color of the given text object.

    Parameters

    • color: number

      The new color to set.

    • text_obj: TextObj

      The text obj.

    Returns void

  • update_text_position(new_position: { x?: number; y?: number }, text_obj: TextObj): void
  • Changes the position of the given text object.

    Parameters

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

      The desired position object.

      • Optional x?: number
      • Optional y?: number
    • text_obj: TextObj

      The text object to move repositioned.

    Returns void

Generated using TypeDoc