2016-03-26 00:47:20 +01:00
# Show Animation
2016-05-20 01:50:02 +02:00
Show a group of image frames (pictures) one after another on the [LED screen ](/device/screen ). It pauses the amount of time you tell it after each frame.
2016-03-26 00:47:20 +01:00
```sig
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
### Parameters
2016-05-20 01:50:02 +02:00
* `leds` is a [String ](/reference/types/string ) that shows which LEDs are on and off, in groups one after another.
* `interval` is an optional [Number ](/reference/types/number ). It means the number of milliseconds to pause after each image frame.
2016-03-26 00:47:20 +01:00
2016-05-20 01:50:02 +02:00
### Example: Animating a group of image frames
In this animation, each row is 15 spaces wide because
there are three frames in the animation, and each frame is
five spaces wide, just like the screen on the BBC micro:bit.
2016-03-26 00:47:20 +01:00
```
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
### ~hint
2016-05-20 01:50:02 +02:00
If the animation is too fast, make `interval` bigger.
2016-03-26 00:47:20 +01:00
### ~
2016-05-20 01:50:02 +02:00
### Example: animating frames with a pause
This example shows six frames on the screen, pausing 500 milliseconds after each frame.
2016-03-26 00:47:20 +01:00
2016-05-20 01:50:02 +02:00
In this animation, each row is 30 spaces wide because
there are six frames in the animation, and each frame is
five spaces wide, just like the screen.
2016-03-26 00:47:20 +01:00
```
basic.showAnimation(`
. . . . . # . . . . . . . . . . . . . # . . . . . # . . . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. # . # . . . # . . . # . # . . . # . . . # . # . . . # . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. . . . . . . . . # . . . . . # . . . . . . . . . . . . . #
`, 500)
```
### ~hint
2016-05-20 01:50:02 +02:00
Use [forever ](/reference/basic/forever ) to show an animation over and over.
2016-03-26 00:47:20 +01:00
### ~
### Lessons
2016-04-16 01:15:08 +02:00
[smiley ](/lessons/smiley ), [snowflake fall ](/lessons/snowflake-fall ), [rotation animation ](/lessons/rotation-animation )
2016-03-26 00:47:20 +01:00