How to mirror/flip sprite?

Status
Not open for further replies.

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
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?
 
Last edited:

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
531
Reaction score
278
First Language
thai
Primarily Uses
RMMV
don't know I edit some character code
this.scale.x *= -1;
and it work
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
426
Reaction score
173
First Language
Dutch
Primarily Uses
RMMV
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 ^^.
 

Raizen

Veteran
Veteran
Joined
Oct 24, 2012
Messages
382
Reaction score
665
First Language
Portuguese
Primarily Uses
RMMV
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.
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
531
Reaction score
278
First Language
thai
Primarily Uses
RMMV
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
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,013
Reaction score
5,326
First Language
Dutch
Primarily Uses
RMXP

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.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

After hearing Wataten's opening several times and knowing what this anime is about, I don't think I like moe anymore.
So I am working on a big DLC package for my game.... and it will add a new intro and extend the ending of the base game, while of course adding additional content to the game... Yeah, that should work! lol
I'm stuck, I'm making some of Mr. N's Dialogue but I can't finish his full Dialogue...heres what I got now [this is the part I'm stuck on] "You treat me like a
bug, I'M SICK OF IT, you had me make these...abominations...well, now..." and at the "Well, now...' part I'm stuck at, anyone got Ideas?

Forum statistics

Threads
107,551
Messages
1,030,459
Members
139,673
Latest member
WDRS
Top