Physics.Arcade#velocityFromRotation()

velocityFromRotation(rotation, speed, point) → {Phaser.Point}

Given the rotation (in radians) and speed calculate the velocity and return it as a Point object, or set it to the given point object.
One way to use this is: velocityFromRotation(rotation, 200, sprite.velocity) which will set the values directly to the sprites velocity and not create a new Point object.

Parameters
Name Type Argument Default Description
rotation number

The angle in radians.

speed number <optional>
60

The speed it will move, in pixels per second sq.

point Phaser.Point | object <optional>

The Point object in which the x and y properties will be set to the calculated velocity.

Returns
  • A Point where point.x contains the velocity x value and point.y contains the velocity y value.
Source code: physics/arcade/World.js (Line 1791)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.