Move to the next frame for the animation for a sprite.
When the last frame is displayed and nextFrame() is executed the first frame is disaplyed.
Use the Animation tab to load multiple images which make up the frames for a labeled animation for your sprite. By default all frames are displayed one after another in round robin fashion. The speed is set by the slider in the Animation tab. Use play()
to restart the animation. Use pause()
to stop the animation.
Mouse over the emoji to move through the animation frames and make it's eyes move!
//Mouse over emoji! var sprite = createSprite(200, 200); sprite.setAnimation("emoji"); sprite.pause(); function draw() { background("white"); drawSprites(); if (mouseIsOver(sprite)) { sprite.nextFrame(); } }
sprite.nextFrame()
No return value. Changes output in the display after drawSprites() is called.
drawSprites()
is called.Found a bug in the documentation? Let us know at documentation@code.org