getMouseAngle( x, y )

Returns the angle from the x and y location given, to the current location of the mouse. This angle is in radians.

A common use for this is to have a player shoot with the mouse, and this then allows you to find the shooting angle from the player to the mouse cursor.

 * Clicking shoots a ball, from the centre of the screen,
 * out to the current mouse location.

// balls location
x = 0
y = 0

// the angle of the ball, null for no angle
angle = null

// speed the ball will travel at
speed = 2

onEachFrame() do
    fill( :black )
    // if user clicks, reset the ball location,
    // and find out where they are shooting to
    c = getControls()
    if c.isLeftClick()
        x = getScreenWidth()/2
        y = getScreenHeight()/2
        angle = c.getMouseAngle( x, y )
    if angle
        // update the location based on the angle
        x = x + speed*angle.cos()
        y = y + speed*angle.sin()
        // draw the ball
        setColor( :blue ) do
            fillCircle( x, y, 32, 32, true )

See also

getMouseX - getMouseY - getMouseXY