Options
All
  • Public
  • Public/Protected
  • All
Menu

This class manages collision between the main concepts of the engine: map, hero, npcs and interactable objects.

Hierarchy

  • Collision

Index

Constructors

Properties

_custom_bodies: {}

Type declaration

  • [label: string]: Phaser.Physics.P2.Body
_dynamic_events_collision_group: CollisionGroup
_hero_collision_group: CollisionGroup
_interactable_objs_collision_groups: {}

Type declaration

  • [layer_index: number]: Phaser.Physics.P2.CollisionGroup
_map_collision_group: CollisionGroup
_npc_collision_groups: {}

Type declaration

  • [layer_index: number]: Phaser.Physics.P2.CollisionGroup
data: GoldenSun
game: Game
max_layers_created: number
MINIMAL_SLOPE: 0.1 = 0.1
ROTATION_NORMAL: directions[] = ...

This variable converts from normal_angle region (floor((angle-15)/30)) to in-game rotation.

SPEED_LIMIT_TO_STOP: 13 = 13
SPEED_LIMIT_TO_STOP_WORLD_MAP: 9 = 9

Accessors

  • get custom_bodies(): {}
  • get dynamic_events_collision_group(): CollisionGroup
  • get hero_collision_group(): CollisionGroup
  • get interactable_objs_collision_groups(): {}
  • get map_collision_group(): CollisionGroup
  • get npc_collision_groups(): {}

Methods

  • change_map_body(new_collision_layer_index: number, sort_sprites?: boolean): void
  • Changes the map body according to a given collision layer index.

    Parameters

    • new_collision_layer_index: number

      Target collision layer.

    • sort_sprites: boolean = false

      if true, it will also sort the sprites in the map after reordering the layers.

    Returns void

  • This function checks whether is necessary to stop when colliding or change the char direction in order to adapt its movement to the collision slope.

    Parameters

    Returns void

  • clear_custom_bodies(): void
  • config_collision_groups(map: Map): void
  • Creates npcs and interactable objects collision groups.

    Parameters

    • map: Map

      the current map.

    Returns void

  • config_collisions(collision_layer: number): void
  • Configs collisions between hero, map, npcs and interactable objects.

    Parameters

    • collision_layer: number

      the current collision layer.

    Returns void

  • config_world(): void
  • create_custom_body(label: string, x: number, y: number, body_type: "box" | "circle" | "polygon", properties: { collision_layer?: number; height?: number; points?: number[][]; radius?: number; width?: number }): Body
  • Creates a custom body on interactable objects collision group. It can be a box, circle or polygon.

    Parameters

    • label: string

      the custom body unique label name.

    • x: number

      the x position of the body.

    • y: number

      the y position of the body.

    • body_type: "box" | "circle" | "polygon"
    • properties: { collision_layer?: number; height?: number; points?: number[][]; radius?: number; width?: number }

      some properties regarding the type of the body.

      • Optional collision_layer?: number

        The target collision layer for the body to be.

      • Optional height?: number

        The height of the box.

      • Optional points?: number[][]

        The array of polygon points.

      • Optional radius?: number

        The radius of the circle.

      • Optional width?: number

        The width of the box.

    Returns Body

    returns the created body.

  • destroy_custom_body(label: string): void
  • Destroys a custom body.

    Parameters

    • label: string

      the unique label of the body to be destroyed.

    Returns void

  • disable_map_collision(sensor_method?: boolean): void
  • Disables collision between hero and map.

    Parameters

    • sensor_method: boolean = false

      if true, disables collision by only setting the map shapes as a sensor.

    Returns void

  • disable_npc_collision(collision_layer?: number): void
  • Disables collision between hero and npcs.

    Parameters

    • Optional collision_layer: number

      if given, disables only on this layer.

    Returns void

  • enable_map_collision(sensor_method?: boolean): void
  • Enables collision between hero and map.

    Parameters

    • sensor_method: boolean = false

      if true, enables collision by only setting the map shapes as not a sensor.

    Returns void

  • enable_npc_collision(collision_layer?: number): void
  • Enables collision between hero and npcs.

    Parameters

    • Optional collision_layer: number

      if given, enables only on this layer.

    Returns void

  • get_polygon_tile_intersection(map: Map, min_x: number, max_x: number, min_y: number, max_y: number, polygon?: number[][]): Map<number, number[][][]>
  • Given a surface range, loop over the tiles in this range and find the intersection polygons for each tile.

    Parameters

    • map: Map

      the current map object.

    • min_x: number

      the min x range in px.

    • max_x: number

      the max x range in px.

    • min_y: number

      the min y range in px.

    • max_y: number

      the max y range in px.

    • Optional polygon: number[][]

      The polygon. The first and last positions are equivalent, and they MUST contain identical values.

    Returns Map<number, number[][][]>

    Returns a JS Map where its key is a location key and its value is the list of polygons for this location key.

Generated using TypeDoc