Phaser API Documentation

  Version: 
hitTest(pointer, gameObjects, camera, [output])

Description:

Performs a hit test using the given Pointer and camera, against an array of interactive Game Objects.

The Game Objects are culled against the camera, and then the coordinates are translated into the local camera space and used to determine if they fall within the remaining Game Objects hit areas or not.

If nothing is matched an empty array is returned.

This method is called automatically by InputPlugin.hitTestPointer and doesn't usually need to be invoked directly.

Parameters:

name type arguments description
pointer Phaser.Input.Pointer

The Pointer to test against.

gameObjects array

An array of interactive Game Objects to check.

camera Phaser.Cameras.Scene2D.Camera

The Camera which is being tested against.

output array <optional>

An array to store the results in. If not given, a new empty array is created.

Returns:
Description:

An array of the Game Objects that were hit during this hit test.

Type:
  • array
Since: 3.0.0