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:
sprite.x and sprite.y properties within the draw() functionsprite.velocityX and sprite.velocityY propertiessprite.setVelocity() or sprite.setSpeedAndDirection()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());
}
sprite.getDirection()
The direction angle of the sprite in degrees.
Found a bug in the documentation? Let us know at documentation@code.org