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
You can create a new sprite using the createSprite()
block.
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.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.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