group.setAnimationEach()
Category:Groups
Sets the image or animation for every sprite in the group.
Use the Animation tab to load and label images and animations for your sprites.
The default image is a gray rectangle.
Examples
var group = createGroup();
group.add(createSprite(100, 200));
group.add(createSprite(300, 200));
function draw() {
background("white");
drawSprites();
if (mouseDown("leftButton")){
group.setAnimationEach("alienPink_1");
}
else {
group.setAnimationEach("alienBlue_1");
}
}
Syntax
group.setAnimationEach(label)
Parameters
Name | Type | Required? | Description |
---|---|---|---|
label | String | The name of an image or animation loaded in the Animation tab. |
Returns
No return value. Changes output in the display after drawSprites() is called.
Tips
- Groups of sprites all have the same functions and you use the dot notation (combining the name of the group, followed by a dot, with the function name) to call the function for that group of sprites.
- Any changes to the properties of a sprite will not be seen until after
drawSprites()
is called.
Found a bug in the documentation? Let us know at support@code.org.