pxt-calliope/docs/reference/game/create-sprite.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR (#529)
* Accessibility changes
2017-09-07 13:42:08 -07:00

893 B

Create Sprite

Create a new LED sprite pointing to the right.

A sprite is like a little LED creature you can tell what to do. You can tell it to move, turn, and check whether it has bumped into another sprite.

game.createSprite(2, 2);

Parameters

  • x: The left-to-right place on the LED screen where the sprite will start out.
  • y: The top-to-bottom place on the LED screen where the sprite will start out.

0 and 4 mean the edges of the screen, and 2 means in the middle.

Example

This program starts a sprite in the middle of the screen. Next, the sprite turns toward the lower-right corner. Finally, it moves two LEDs away to the corner.

let item = game.createSprite(2, 2);
item.turn(Direction.Right, 45);
item.move(2);

See also

move, turn, is-touching