pxt-common-packages
Version:
Microsoft MakeCode (PXT) common packages
77 lines (66 loc) • 2.32 kB
Markdown
# animation Frames
A sequence of image frames for an animation.
```sig
animation._animationFrames(null)
```
The frames of an animation are set as an array of images. The block for containing the frames provides access to the image editor to create new frames and edit the ones already in the animation.
## Parameters
* **frames**: an array of images that create the animation.
## Example #example
Create and run an animation of a person walking. Click on the animation frames block to edit the animation. Loop the animation and then
stop it by pressing button **A**.
```blocks
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
animation.stopAnimation(animation.AnimationTypes.All, mySprite)
})
let mySprite: Sprite = null
scene.setBackgroundColor(1)
mySprite = sprites.create(img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`, SpriteKind.Player)
let walker = animation._animationFrames([img`
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
`])
animation.runImageAnimation(
mySprite,
walker,
500,
true
)
```
## See Also #seealso
[run image animation](/reference/animation/run-image-animation),
[run movement animation](/reference/animation/run-movement-animation)
```package
animation
```