accelerateToPointer(displayObject, pointer, speed, xSpeedMax, ySpeedMax) → {number}
Sets the acceleration.x/y property on the display object so it will move towards the target at the given speed (in pixels per second sq.)
You must give a maximum speed value, beyond which the display object won't go any faster.
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. | ||
pointer | Phaser.Pointer | <optional> | The pointer to move towards. Defaults to Phaser.Input.activePointer. | |
speed | number | <optional> | 60 | The speed it will accelerate in pixels per second. |
xSpeedMax | number | <optional> | 500 | The maximum x velocity the display object can reach. |
ySpeedMax | number | <optional> | 500 | The maximum y velocity the display object can reach. |
Returns
The angle (in radians) that the object should be visually set to in order to match its new trajectory.
- Source code: physics/arcade/World.js (Line 1858)
Please login to continue.