group.setMirrorYEach()

Category:Groups

Sets the vertical 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.setMirrorYEach(-1);
  }
  else {
    group.setMirrorYEach(1);
  }
}

Syntax

group.setMirrorYEach(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 vertically.

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 documentation@code.org