Flip an image in corona sdk

Hi,

I am newbie to corona sdk. i need image flip animation in corona sdk.

please reply this post…

Regards,

Hari

You can use:

object.xScale = -1  to flip right,left or

object.yScale = -1 to flip up,down

or use both to flip diagonally

Hi Hari,

Icy Spark is correct… just note that flipping will not (at this time) flip a physics body, if you’re using it that way. It will flip the image, but the physics body will retain its core orientation. I have, however, asked the engineers to look into this and see if we can provide a “true” flip with physics… hopefully it can happen before too long. :slight_smile:

Brent

thank you Icy Spark and Brent Sorrentino. It’s working fine.

You can use:

object.xScale = -1  to flip right,left or

object.yScale = -1 to flip up,down

or use both to flip diagonally

Hi Hari,

Icy Spark is correct… just note that flipping will not (at this time) flip a physics body, if you’re using it that way. It will flip the image, but the physics body will retain its core orientation. I have, however, asked the engineers to look into this and see if we can provide a “true” flip with physics… hopefully it can happen before too long. :slight_smile:

Brent

thank you Icy Spark and Brent Sorrentino. It’s working fine.

Hey Brent - time to get the BANHAMMER ™ out - this guy’s two posts are both spam.

Thanks @SegaBoy! The hammer has fallen (bot is now banned). :slight_smile:

Brent

Hey Brent - time to get the BANHAMMER ™ out - this guy’s two posts are both spam.

Thanks @SegaBoy! The hammer has fallen (bot is now banned). :slight_smile:

Brent

thank you for sharing such wonderful module.  working well in flipping an image, just what i was looking for. but physical body fail just like the above reply. looking forward for coronalabs sdk improving.

Hi @white.image,

While flipping an image using the scaling methods will not affect the physics body, writing a quick flipping function should be relatively easy. At a quick thought, you’d want to:

  1. loop through the body’s x/y coordinate table by pairs, but do so backwards so you maintain the proper clockwise declaration required by physics bodies.

  2. for each pair, negate (multiply by -1) either the x or y coordinate, depending on whether you’re flipping it horizontal or vertical

  3. re-insert the pairs into a new table, and then return that table as the flipped body declaration.

It’s still a bit limited because you’d need to remove the previous body and then replace it, which should happen during a non-time-critical stage, but generally speaking you should try to add physics bodies during non-time-critical points anyway, especially if you’re doing a big loop of them.

Hope this helps,

Brent Sorrentino

thank you for sharing such wonderful module.  working well in flipping an image, just what i was looking for. but physical body fail just like the above reply. looking forward for coronalabs sdk improving.

Hi @white.image,

While flipping an image using the scaling methods will not affect the physics body, writing a quick flipping function should be relatively easy. At a quick thought, you’d want to:

  1. loop through the body’s x/y coordinate table by pairs, but do so backwards so you maintain the proper clockwise declaration required by physics bodies.

  2. for each pair, negate (multiply by -1) either the x or y coordinate, depending on whether you’re flipping it horizontal or vertical

  3. re-insert the pairs into a new table, and then return that table as the flipped body declaration.

It’s still a bit limited because you’d need to remove the previous body and then replace it, which should happen during a non-time-critical stage, but generally speaking you should try to add physics bodies during non-time-critical points anyway, especially if you’re doing a big loop of them.

Hope this helps,

Brent Sorrentino