moveToPointer(displayObject, speed, pointer, maxTime) → {number}
Move the given display object towards the pointer at a steady velocity. If no pointer is given it will use Phaser.Input.activePointer.
If you specify a maxTime then it will adjust the speed (over-writing what you set) so it arrives at the destination in that number of seconds.
Timings are approximate due to the way browser timers work. Allow for a variance of +- 50ms.
Note: The display object does not continuously track the target. If the target changes location during transit the display object will not modify its course.
Note: The display object doesn't stop moving once it reaches the destination coordinates.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
displayObject | any | The display object to move. | ||
speed | number | <optional> | 60 | The speed it will move, in pixels per second (default is 60 pixels/sec) |
pointer | Phaser.Pointer | <optional> | The pointer to move towards. Defaults to Phaser.Input.activePointer. | |
maxTime | number | <optional> | 0 | Time given in milliseconds (1000 = 1 sec). If set the speed is adjusted so the object will arrive at destination in the given number of ms. |
Returns
The angle (in radians) that the object should be visually set to in order to match its new velocity.
- Source code: physics/arcade/World.js (Line 1701)
Please login to continue.