Physics.Arcade#accelerateToObject()

accelerateToObject(displayObject, destination, 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.

destination any

The display object to move towards. Can be any object but must have visible x/y properties.

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
number -

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 1829)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.