Class: CoordinatesHelper

CoordinatesHelper

A static class to handle coordinate transformations between objects


new CoordinatesHelper()

Methods


<static> contains(point, sprite)

Checks if a point is contained inside a sprite

Parameters:
Name Type Description
point Phaser.Point

A Point

sprite Phaser.Sprite | Phaser.Group

A Sprite or Group

Returns:
Type
boolean

<static> findCommonAncestor(element)

Given an object, it returns the list of its ancestors, from the nearest to the farest

Parameters:
Name Type Description
element Phaser.Sprite | Phaser.Group

The Sprite or Group


<static> getTree(element)

Given an object, it returns the list of its ancestors, from the nearest to the farest

Parameters:
Name Type Description
element Phaser.Sprite | Phaser.Group

The Sprite or Group


<static> pointInAncestor(sprite, ancestor [, pivot])

Given a sprite and one of its ancestors, it returns the coordinates of the sprite relative to its ancestor coordinate system

Parameters:
Name Type Argument Default Description
sprite Phaser.Sprite

A Sprite

ancestor Phaser.Sprite | Phaser.Group

A Sprite's ancestor

pivot Phaser.Point <optional>
new Phaser.Point(0.5, 0.5)

The pivot

Returns:

The computed point

Type
Phaser.Point

<static> pointInDescendant(point, reference, descendant)

Converts a point in an element coordinate system in one of it's descendant coordinates

Parameters:
Name Type Description
point Phaser.Point

A Point in reference coordinate system

reference Phaser.Sprite | Phaser.Group

A reference Sprite or Group

descendant Phaser.Sprite | Phaser.Group

A descendant Sprite or Group

Returns:

The computed point

Type
Phaser.Point

<static> transformCoordinates(source, destination)

Given a source and destination graphic, it returns the coordinates of source related to the destination coordinate system

Parameters:
Name Type Description
source Phaser.Sprite | Phaser.Group

The Sprite or Group to be dragged

destination Phaser.Sprite | Phaser.Group

The Sprite or Group to be dragged

Returns:

The computed point

Type
Phaser.Point