How to mirror/flip sprite?

Status
Not open for further replies.

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
424
Reaction score
171
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
529
Reaction score
275
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
424
Reaction score
171
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
381
Reaction score
661
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
529
Reaction score
275
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
7,862
Reaction score
5,240
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

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top