Put objects inside a box with foreground & background walls

Hi everybody,

I have to code a simple game with Flash, and I'm using WCK for the physics.

The player must control a box, and while some little objects fall from the "sky", the player must catch them to get as much points as possible. The objects shall fall inside the box.

For the box, we have created inside the Flash IDE a custom b2Body object, which consists of 3 layers, so as to get a simple 3D effect. Here you can see a sketch:

Image

We have for the box graphics for the foreground and background (layers 1 and 3, black), and in the 2nd layer (red) we have the Box2D walls that hold the falling objects inside them. And here comes the problem. We couldn't place the falling objects in the same level as layer 2, between the foreground and background walls (layers 1 and 3 - black in the picture). We just could either get them in front of the box or behind, but not inside. Is there a way with Box2DAS / WCK to define a z-index for each shape or a trick to simulate this simple "3D" effect?

Thanks for your help!
Sounds like this is a limitation of the flash DOM. Are your front-box and back-box symbols inside one main "box" symbol? In that case, the other physics objects can only be in-front-of or behind the box symbol. Sounds like you'll have to break this symbol apart and manually position the box-front and box-back based on the position of the main box physics object each timestep. That way the box-front can be on a higher layer on the box-back on a lower layer, but their still direct children of the same object (the world).
I tried to do it with 2 different custom shapes (one for the frond and one for the back), and then "stick" them with two joints. It worked, but I find your solution better for the performance.

Thanks!

Original thread: https://box2d.org/forum/viewtopic.php?t=8118