A sprite is the name we give to a collection of values in Game Lab that represents a character in a story, animation, or game. A sprite can be stored in a variable with a label, but unlike values you've stored in variables before, such as numbers, a sprite lets you store many related values all under the same label

Creating a Sprite

You can create a new sprite using the createSprite() block.

  1. The sprite as drawn on screen. In this case, our sprite is located at (200, 200), the center of the screen, and has been assigned the animation "bunny"
  2. The createSprite() block, which creates a new sprite at (200, 200) and assigns it to the variable label my_bunny. Note that just creating the sprite doesn't yet draw it on the screen. That will happen later.
  3. The sprite.setAnimation() block assigns an animation (or image) to the sprite. In this case, we're using an animation named "bunny", which was added in the animation tab. Notice that instead of the default variable name sprite, we've updated this to my_bunny.setAnimation() so that it changes the animation of the my_bunny sprite.
  4. Because sprites are just values stored as variables, they don't automatically get drawn on the screen. The drawSprites() block tells Game Lab to draw all of the sprites that have been created onto the screen.

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