Rotate Image but not physics object

Hi everyone, does corona have any built in api to rotate just the image of a physics body besides just rotating the entire object?  Haven’t been able to find anything so I thought I’d ask just want to check before I come up with my own round about solution.  Thanks.

not understanding what do you mean by image and entire object

You can consider using fills, see tutorials:

https://coronalabs.com/blog/2013/10/24/tutorial-fills-and-strokes-in-graphics-2-0/

http://coronalabs.com/blog/2013/11/07/tutorial-repeating-fills-in-graphics-2-0/

Fills can be rotated independently of the object they are attached to, using object.fill.rotation = x

without knowing you exact usage, a couple possibilities come to mind:

  1. add your display object (at 0,0) to a display group (then position via group), then add *group* to physics (instead of its contained display object). you can now freely rotate the object but physics just sees the group’s bounding box. this is a “gotcha” that most try to avoid, but might actually be what you’re after. (tho note that group’s dimensions, as physics see it, can change based on object’s rotation)

  2. create two separate objects and weld them together, one is your “real” body (isVisible=false), the other is just a “decal” (isVisible=true, fixed rotation, as set by you, isSensor=true, density=0)

  3. similar to 2) above, except don’t use a second physics body and weld just do it yourself (like in a enterFrame loop) with one (invisible) physics body and a sprite. give your physics body a reference to its sprite, and have body reposition sprite to it’s own x/y each frame.

fwiw, hth

Thanks everyone for the replys.  Sorry that my question was unclear.  I’d considered options 2 and 3 that davbollinger suggested and I think that I am going to use method 3.  Again thanks everyone!

the third method seems like a good solution to rotate image in separate, has anyone tried it, is it work?

I used method 3 and it worked just fine for me.  I’d definitely recommend it and for most cases can’t see much that could go wrong with it.  Good luck and hopefully it works for you!

not understanding what do you mean by image and entire object

You can consider using fills, see tutorials:

https://coronalabs.com/blog/2013/10/24/tutorial-fills-and-strokes-in-graphics-2-0/

http://coronalabs.com/blog/2013/11/07/tutorial-repeating-fills-in-graphics-2-0/

Fills can be rotated independently of the object they are attached to, using object.fill.rotation = x

without knowing you exact usage, a couple possibilities come to mind:

  1. add your display object (at 0,0) to a display group (then position via group), then add *group* to physics (instead of its contained display object). you can now freely rotate the object but physics just sees the group’s bounding box. this is a “gotcha” that most try to avoid, but might actually be what you’re after. (tho note that group’s dimensions, as physics see it, can change based on object’s rotation)

  2. create two separate objects and weld them together, one is your “real” body (isVisible=false), the other is just a “decal” (isVisible=true, fixed rotation, as set by you, isSensor=true, density=0)

  3. similar to 2) above, except don’t use a second physics body and weld just do it yourself (like in a enterFrame loop) with one (invisible) physics body and a sprite. give your physics body a reference to its sprite, and have body reposition sprite to it’s own x/y each frame.

fwiw, hth

Thanks everyone for the replys.  Sorry that my question was unclear.  I’d considered options 2 and 3 that davbollinger suggested and I think that I am going to use method 3.  Again thanks everyone!

the third method seems like a good solution to rotate image in separate, has anyone tried it, is it work?

I used method 3 and it worked just fine for me.  I’d definitely recommend it and for most cases can’t see much that could go wrong with it.  Good luck and hopefully it works for you!