sprite.getDirection()

Category:Sprites

The sprite's movement direction in degrees.

The direction angle is a number from -180 to 180, 0 is to the right, clockwise increasing.

The velocity of the sprite, its speed and direction, can be set in many ways:

Examples

Circling

Move a sprite in a circle.

// Move a sprite in a circle.
var sprite = createSprite(200, 100);
function draw() {
  background("white");
  drawSprites();
  sprite.setSpeedAndDirection(2,sprite.getDirection()+1);
  console.log(sprite.getDirection());
}

Syntax

sprite.getDirection()

Returns

The direction angle of the sprite in degrees.

Found a bug in the documentation? Let us know at documentation@code.org