apply transform to sprite image
Problem it solves
You want to flip or rotate a sprite's image—for example to face the other direction—without redrawing it by hand.
What this block does
Flips or rotates a sprite's current image in place: horizontal flip, vertical flip, or a 90/180/270 degree clockwise rotation.
The block
Block ID: spriteutiltransformspriteimage
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite to transform |
| transform | ImageTransform | — | flip horizontal, flip vertical, or rotate 90/180/270 degrees clockwise |
Example
let mySprite = sprites.create(img`.`, SpriteKind.Player) let myEnemy = sprites.create(img`.`, SpriteKind.Enemy) spriteutils.transformSpriteImage(mySprite, spriteutils.ImageTransform.FlipHorizontal)
Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.