Is it possible to create a shape inside a movieClip?

Hi, my name is Marco, from Brazil!
I'm kind of new with box2d, and i would like to know if is possible to create a shape inside a movieClipe instead of creating him on the stage ?


thanks for your time.



Marco
Hi Marco.
You need to clarify a little what you want to do.
In general you construct bodies from shapes and add them to the physics world, which handles the simulation.
Those bodies have no visual representation, they're just numbers of coordinates and other properties to the engine.
It's your task to add visual assets (movie clips, images) and keep the in synch with their responding body.
In that sense, and to answer your question, you can add those "skins" wherever you want.
Since those would obviously be object sublassing DisplayObject, they could be added to any DisplayObjectContainer.
Sorry vitalee, let me explain what i'm planning to do.
I'm creating a race car, where the car(a box2d polygono) shape stays at the center of the stage, and the cenario moves when you accelerate and turn te car.
Although, to make the cenario limits (some box2d shapes), i would need to create thoses limits inside the movieClip of the cenario, so when i accelerate or turn, the limits are gonna move as the cenario moves.

I don't know if that's the best way to do what i what to do... as i said, i'm kind of new with all this stuff.

Thanks !
the scenario: the car stays centered on the stage and all the surrounding environment moves around it in opposite direction.
the way to achiev this result is to place the car, envronment..etc in one container (MovieClip).
then you move the car within that container and update container's position to keep the car visually centered on stage.
consider this exmaple.
stage size is 500x250.
the car is placed inside container and it's dimensions are 1200x800.
when you drive the car to the coordinates x:600, y:400 inside the container, to keep the car centered on stage you have to move the container to pos :
x = 250 - 600 = -350, / (stage.stageWidth / 2) - car.x in container
y = 125 - 400 = -275 / (stage.stageHeight / 2) - car.y in container
that's how you get the illusion that everything around the car moves.
if you're having difficulties to grasp the idea, do a search for "game camera scrolling"
No man, the problem is not that.

I want that the box from Box2D follow my movieclip. If I change x and y from my stage, only the graphic will change, not the box form Box2d.
The box2D should move as the movieclip moves.
well you can manually sync the position/rotation of physical body with that of a movie clip, if that's what you're after
b2Body::SetXForm(position:b2Vec2, angle:Number) : Boolean
wow, thank you so much! that really helps!

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