Phaser API Documentation

  Version: 
velocityFromAngle(angle, [speed], [vec2])

Description:

Given the angle (in degrees) 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: velocityFromAngle(angle, 200, sprite.body.velocity) which will set the values directly to the sprite's velocity and not create a new vector object.

Parameters:

name type arguments Default description
angle number

The angle in degrees calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative)

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.

Returns:
Description:

The Vector2 that stores the velocity.

Since: 3.0.0