Skip to content

Animate a sprite with costumes

Cycling through costumes on every tick creates the illusion of movement. Give your sprite at least two costumes, then loop through them with a short delay between each switch.

whenGreenFlag(() => {
forever(() => {
nextCostume();
wait(0.1);
});
});

The sprite steps through its costumes continuously. Adjust the wait value to control animation speed β€” 0.1 is fast, 0.5 is slow.

  • whenGreenFlag β€” run code when the green flag is clicked
  • forever β€” repeat a block of code indefinitely
  • wait β€” pause the script for a number of seconds
  • nextCostume β€” switch to the next costume
All recipes