group.setMirrorXEach()
Sets the horizontal mirroring for every sprite in the group.
To mirror the image or animation of a sprite you can either use the Animation tab and create and name each mirror you need, or just use the setMirrorXEach()
and setMirrorYEach()
commands.
Examples
var group = createGroup();
group.add(createSprite(100, 200));
group.add(createSprite(300, 200));
group.setAnimationEach("gnome_1");
function draw() {
background("white");
drawSprites();
if (mouseDown("leftButton")){
group.setMirrorXEach(-1);
}
else {
group.setMirrorXEach(1);
}
}
Syntax
group.setMirrorXEach(dir)
Parameters
Name | Type | Required? | Description |
---|---|---|---|
dir | Number | If the parameter is 1, the sprites are displayed normally. If the parameter is -1, the sprites are flipped horizontally. |
Returns
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.