How to mirror/flip sprite?

JavaScript:
this.sprite = new Sprite(bmp);
this.addChild(this.sprite);
this.sprite.scale.x = -1; // <<< this line causes the sprite to become invisible. Why? Why won't it mirror?

JavaScript:
this.sprite.scale.set(-1,1); // also doesn't work. No error either, just turns invisible.
this.sprite.scale.set(2,1); // Works, but it's a positive value so it isn't mirrored...
this.sprite.scale.x = 2; // Works, but it's a positive value so it isn't mirrored...


Also, are we supposed to add a loadlistener to each sprite we use in case the bitmap hasn't yet been loaded?
don't know I edit some character code
this.scale.x *= -1;
and it work
Okay, the bug was really silly... When you flip a sprite the effective render location (of course!) also changes. In my case it went off-screen... So the code was correct I just had to move it ^^.
Ah, just one thing you can use anchor to set the rotation axis, so if you set it like .
this.sprite.anchor.x = 0.5;
this.sprite.anchor.y = 0.5;

When you mirror it, you won't need to move it.
Ah, just one thing you can use anchor to set the rotation axis, so if you set it like .
this.sprite.anchor.x = 0.5;
this.sprite.anchor.y = 0.5;

When you mirror it, you won't need to move it.
but I always like top left because I don’t like to think again about the half coordinate xD

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-mirror-flip-sprite.119945/