We're going to explore how to give sprites multiple costumes and swap between them. For this project, we're just going to be making a simple animation, but there are lots of ways to use this pattern.
Play this demo in full screen.
1) Chose costumes for your sprite. It's easiest to use the example running sprites, like the demo.
If you are creating your own (or using costumes from a sprite sheet you like), it's best to have each costume be a similar size. Upload each costume as a separate sprite.
Play this demo in full screen.
2) Make a list that contains all the URLs for the costumes of your sprite.
3) Make a variable that will keep track of which costume in the list you will display. Make a text sprite to display this variable so you can understand what your variable is doing.
Play this demo in full screen.
4) Make your variable cycle through the costume numbers by adding 1 to it every second. When your variable reaches the length of the list, set it back to 0. (Since Woof is Zero-Indexed, we use '0' to refer to the first item in a list).
Play this demo in full screen.
5) Each time your variable changes, get the appropriate URL from your list and use it to change your sprite's costume. (You can also speed up the animation by changing how often the variable changes)
Play this demo in full screen.