Dynamically add additional body to multi-element body?

In my game, the hero can collide with bullets, monsters etc. But the hero can also pick up a shield (circular shape around the hero) that makes the enemy objects bounce off it without damaging him.

The “hero” is a multi-element physics body like this:

local properties1 = { density = 10.0, friction = 0.0, bounce = 0.0, shape = { [coordinates] } } local properties2 = { density = 10.0, friction = 0.0, bounce = 0.0, shape = { [coordinates] } } physics.addBody(hero, "dynamic", properties1, properties2)

When the hero picks up the shield, I add an image on top of the hero (the visible “shield circle”). I also need to add another physics body with the same size and shape as the shield circle so that stuff are stopped by the shield without reaching the hero while the shield is up.

The problem is that when I try to add another body (same logic as in the code above but with a 10 msec delay inside the hero’s collision detection function) it does not “register”. Nothing is displayed when I run it in hybrid draw mode. My questions are:

  1. Is it not possible to dynamically add additional physics body elements?

  2. Is there a better way to achieve this than by adding another physics body element?

EDIT: basically, I want the equivalent of being able to dynamically toggle on and off indivvidual physics elements in a multielement body. If this can be achieved in a whole different way without even using multi-element bodies, that also ok.

I solved it, in case anyone is interested:

Using the tips in the multi-element body tutorial, I simply used a pre-collision listener to void all contact events with the shield unless it was “active” in the game (i.e. picked up by the hero).

The turorial:

https://coronalabs.com/blog/2013/01/08/working-with-multi-element-physics-bodies/

I solved it, in case anyone is interested:

Using the tips in the multi-element body tutorial, I simply used a pre-collision listener to void all contact events with the shield unless it was “active” in the game (i.e. picked up by the hero).

The turorial:

https://coronalabs.com/blog/2013/01/08/working-with-multi-element-physics-bodies/