sprite.getSpeed()

Category:Sprites

The sprite's scalar speed.

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

Examples

Spiral

Move a sprite in a spiral.

// Move a sprite in a spiral.
var sprite = createSprite(200, 100, 20, 20);
function draw() {
  background("white");
  drawSprites();
  sprite.setSpeedAndDirection(sprite.getSpeed()+0.01,sprite.getDirection()+1);
}

Syntax

sprite.getSpeed()

Returns

The speed of the sprite in pixels per frame..

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