pxt-calliope/docs/reference/basic/show-animation.md

62 lines
1.6 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Show Animation
2016-04-13 17:27:45 +02:00
Show a series of image frames on the [LED screen](/device/screen), pausing the specified time after each frame.
2016-03-26 00:47:20 +01:00
```sig
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
### Parameters
2016-04-13 17:27:45 +02:00
* `leds` - [String](/reference/types/string); a series of LED on/off states
* `interval` - [Number](/reference/types/number); the number of milliseconds to pause after each image frame
2016-03-26 00:47:20 +01:00
### Show a series of image frames
```
basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)
```
### ~hint
If the series of images appear too fast, increase the value of the *interval* parameter.
### ~
### Example: animating frames
The following example creates an image with six frames and then shows each frame o the screen, pausing 500 milliseconds after each frame:
```
basic.showAnimation(`
. . . . . # . . . . . . . . . . . . . # . . . . . # . . . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. # . # . . . # . . . # . # . . . # . . . # . # . . . # . .
. . # . . . . . . . . . # . . . . . . . . . # . . . . . . .
. . . . . . . . . # . . . . . # . . . . . . . . . . . . . #
`, 500)
```
### ~hint
2016-04-13 17:27:45 +02:00
Use [forever](/reference/basic/forever) to continually repeat an animation
2016-03-26 00:47:20 +01:00
### ~
### Lessons
2016-04-13 17:27:45 +02:00
[smiley](/lessons/smiley), [bounce image](/lessons/bounce-image), [snowflake fall](/lessons/snowflake-fall), [rotation animation](/lessons/rotation-animation)
2016-03-26 00:47:20 +01:00