How to reset the world?

There is a way to reset everything to the first step?

right now i am doing like this:

Code:
if(start){            
for (bb = m_world.m_bodyList; bb; bb = bb.m_next){
if (bb.m_userData is Sprite){                  
if(bb.m_userData.name=="Ball"){ballPosition=new Point(bb.GetPosition().x,bb.GetPosition().y);}                  
}}}         
         
if(reset){               
for (bb = m_world.m_bodyList; bb; bb = bb.m_next){
if (bb.m_userData is Sprite){                  
if(bb.m_userData.name=="Ball"){bb.SetXForm(new b2Vec2(ballPosition.x,ballPosition.y),0);}   
}}}               


but it doesnt work... everytime i reset and restart the ball fall down faster and faster every time 🙁
set the "m_linearVelocity.x" and "m_linearVelocity.y" of your ball to "0" when you put it back in position.
Oh ok, Also i have noticed that once the ball touchs the worl boundaires it doesnt reset anymore, it stais there frozen... how do i solve this problem?
That's normal behavior. One approach is to create boxes at the edges of the world. If something collides with those boxes, you can count them as out of bounds.
If i dont want to create those boxes there is another way to reset?
http://www.box2d.org/wiki/index.php?title=Manual/AS3#World_Boundary
Check that link out. Should be what you are asking for
Thank you for the answer, I didnt undertsand very much... i think i will create boundaries boxes... 😀
its easier 🙂
VengantMjolnir
I am interesting to use the BoundaryListener
just add the code of destroy body inside the function of Violation ??
is it right?
I tried, but it just frozen the bodies which hit the boundary....
what's the problem?
Thanks.
It would be a REALLY good idea to read the documentation. The answer to your question is in there.

Sorry if that is a short reply, but I've answered this question already today, and a few times in the last month... and I've seen it asked and answered.

In short, you can't modify the physics world from inside the contact/boundary listener because that happens inside the time step... and it might/probably will result in wierd things and or errors. Read the docs, do a search on the forums and if you still have a question then I'm sure you'll get help.

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