The y position of the center of the sprite.
The default y position is 0. All sprite properties can be both accessed and updated.
Move a sprite by incrementing sprite.y within the draw function.
// Move a sprite by incrementing sprite.y within the draw function.
var sprite = createSprite(200, 200);
function draw() {
background("white");
sprite.x = sprite.y-5;
drawSprites();
}
var sprite = createSprite(200,200); console.log(sprite.y); drawSprites(); sprite.y = 50; console.log(sprite.y); drawSprites(); sprite.y = sprite.y * 7; console.log(sprite.y); drawSprites();
sprite.y
The y coordinate of the center of the sprite.
sprite.velocityX, sprite.velocityY, setVelocity(), sprite.setSpeedAndDirection()drawSprites() is called.Found a bug in the documentation? Let us know at documentation@code.org