accelerateToXY(displayObject, x, y, speed, xSpeedMax, ySpeedMax) → {number}
Sets the acceleration.x/y property on the display object so it will move towards the x/y coordinates 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. | ||
x | number | The x coordinate to accelerate towards. | ||
y | number | The y coordinate to accelerate towards. | ||
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 1888)
Please login to continue.