[SOLVED] How to flip objects with code

I would like to know how to make an objet be flipped by code, like if it’s facing right it’ll be facing left

Hey! @Jordy,

You can do that by changing the scaleX of the object
this.scaleX=-1
and
this.scaleX=1

More information on the object’s scale can be found here: https://www.wickeditor.com/#/learn/reference

2 Likes

It didn’t work, but thanks for trying to help

Why? That always works for me.

Try it:
FlipDemo10-6-2021_16-59-48.wick (2.1 KB)

then maybe what you’re looking for is this.scaleX *= -1;. this will toggle the direction (because multiplying by -1 inverts the number). what cosmicknight gave is what you would use if you wanted to use a hardcoded scaleX.

and make sure the code is inside the clip’s object. putting this.scaleX *= -1 in a frame makes no sense because the frame doesn’t have a scaleX. you can do insertClipName.scaleX *= -1, with insertClipName being the name of your clip.

2 Likes

ok now I see that it works, Thanks!