The x position of the center of the sprite.
The default x position is 0. All sprite properties can be both accessed and updated.
Move a sprite by incrementing sprite.x within the draw function.
// Move a sprite by incrementing sprite.x within the draw function.
var sprite = createSprite(200, 200);
function draw() {
background("white");
sprite.x = sprite.x+5;
drawSprites();
}
var sprite = createSprite(200, 200); console.log(sprite.x); drawSprites(); sprite.x = 50; console.log(sprite.x); drawSprites(); sprite.x = sprite.x+300; console.log(sprite.x); drawSprites();
sprite.x
The x 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