Sets the sprite's vertical mirroring.
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 mirrorX()
and mirrorY()
commands.
Flip the gnome with left and right clicks.
// Flip the gnome with left and right clicks. var sprite = createSprite(200, 200); sprite.setAnimation("gnome_1"); function draw() { background("white"); drawSprites(); if (mouseWentDown("leftButton")) { sprite.mirrorX(sprite.mirrorX() * -1); } if (mouseWentDown("rightButton")) { sprite.mirrorY(sprite.mirrorY() * -1); } }
sprite.mirrorY(dir)
Name | Type | Required? | Description |
---|---|---|---|
dir | Number | If the parameter is 1, the sprite is displayed normally. If the parameter is -1, the sprite is flipped vertically. If no parameter is given, the function returns the current y mirroring value. |
If the parameter is given, there is no return value and it changes output in the display after drawSprites() is called. If the parameter is not given, the current mirroring value is returned, 1 or -1.
Found a bug in the documentation? Let us know at documentation@code.org