Best / correct way to overlay 2 objects?

I have a physics body which is created from an image. When the user taps I want an alternate image to display in the exact same position as the body and fade out.

I’ve read that with Corona you can’t *change* an image at runtime so I’m thinking I need a second image object which (when the body is tapped) I can show the new image and then fade out the new “overlay” image.

This works fine apart from the fact that the original image/body is moving. I need to ensure that the x & y of the overlay is exactly the same even when moving.

I’m thinking maybe a weld joint - any advice?
[import]uid: 8353 topic_id: 3387 reply_id: 303387[/import]

Group the two objects together and move the group [import]uid: 5354 topic_id: 3387 reply_id: 10073[/import]

Thanks. Movement in this case can also caused by gravity and other object collisions.

Is this still the way to go? [import]uid: 8353 topic_id: 3387 reply_id: 10074[/import]

You cant use groups with physics as it gets complicated

Use sprites, 2 frames but that wont get the fade between objects

You could have an enter frame listener update the second object with the x , y and rotation of the first. Always have both on screen but alter the alpha of the 2 so only one shows at once [import]uid: 5354 topic_id: 3387 reply_id: 10117[/import]

A came to the same conclusion earlier and coded it up.

I ended up using a physics object and overlaying an image in the game loop - works fine but I wondered if there was a “better” way.

Thanks for confirming my suspicion that there isn’t! [import]uid: 8353 topic_id: 3387 reply_id: 10121[/import]

Yeah Physics can complicate things so its best to keep things as simple as you can in the setup [import]uid: 5354 topic_id: 3387 reply_id: 10122[/import]