setInteractiveCandidateHandler(callback, context)
Adds a callback that is fired every time Pointer.processInteractiveObjects
is called.
The purpose of processInteractiveObjects
is to work out which Game Object the Pointer is going to
interact with. It works by polling all of the valid game objects, and then slowly discounting those
that don't meet the criteria (i.e. they aren't under the Pointer, are disabled, invisible, etc).
Eventually a short-list of 'candidates' is created. These are all of the Game Objects which are valid
for input and overlap with the Pointer. If you need fine-grained control over which of the items is
selected then you can use this callback to do so.
The callback will be sent 3 parameters:
1) A reference to the Phaser.Pointer object that is processing the Items.
2) An array containing all potential interactive candidates. This is an array of InputHandler
objects, not Sprites.
3) The current 'favorite' candidate, based on its priorityID and position in the display list.
Your callback MUST return one of the candidates sent to it.
Parameters
Name | Type | Description |
---|---|---|
callback | function | The callback that will be called each time |
context | object | The context in which the callback will be called. |
- Source code: input/Input.js (Line 473)
Please login to continue.