Given the rotation (in radians) and speed calculate the velocity and return it as a vector, or set it to the given vector object. One way to use this is: velocityFromRotation(rotation, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object.
name | type | arguments | Default | description |
---|---|---|---|---|
rotation | number |
The angle in radians. |
||
speed | number | <optional> | 60 |
The speed it will move, in pixels per second squared |
vec2 | Phaser.Math.Vector2 | <optional> |
The Vector2 in which the x and y properties will be set to the calculated velocity. |
The Vector2 that stores the velocity.