pxt-calliope/docs/reference/basic/show-animation.md
2016-03-25 16:47:20 -07:00

1.7 KiB

Show Animation

Show a series of image frames on the LED screen, pausing the specified time after each frame.

basic.showAnimation(`
. . # . . . # # # . . # # # .
. # # . . . . . # . . . . # .
. . # . . . . # . . . # # # .
. . # . . . # . . . . . . # .
. . # . . . # # # . . # # # .
`)

Parameters

  • leds - String; a series of LED on/off states
  • interval - Number; the number of milliseconds to pause after each image frame

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

Use forever to continually repeat an animation

~

Lessons

smiley, bounce image, snowflake fall, rotation animation