Page 1 of 1

Rotation of an object in the other side

Posted: Sat Oct 14, 2017 2:19 pm
by FLYNSXCOOL
I made two versions, one looks left the other looks right. Implemented a change of direction with the removal of the body and create a new one.
But on low laptop the game freezes at the moment of reversal.
How did you solved this problem? Maybe I need both versions of the body load while a second body to do not active? Then rearrange them and do not active the first body. Or to throw from World1 to World2 ?

Re: Rotation of an object in the other side

Posted: Sat Oct 14, 2017 3:57 pm
by FLYNSXCOOL
We Can take all the fixtures and replace them with other forms (shapes). Then take the connection information and recreate connections with recalculated data but will it be faster??? Loader Json makes this way of the files.

Re: Rotation of an object in the other side

Posted: Sun Oct 15, 2017 6:06 pm
by iforce2d
What language are we talking about?
If you run your program as as debug build, you should be able to use the debugger to step into the code while it is running to see what it is doing.

Is it just a single body you want to flip? Replacing the whole body could be a lot of trouble because you need to manually set the velocity, rotation, angular velocity etc. Yes, it would be better to have two sets of fixtures, and switch between using different fixtures.

If you want to flip multiple bodies (and a structure of joints) then you will need to replace all the bodies. I don't think the result will look very good...

Re: Rotation of an object in the other side

Posted: Mon Oct 16, 2017 3:47 pm
by FLYNSXCOOL
Image

Code: Select all

b2dJson jsonR;
jsonR.readFromFile("obj/car_r.json", errorMsg, &World);
b2dJson jsonL;
jsonL.readFromFile("obj/car_l.json", errorMsg, &World);
manipulation with

Code: Select all

->SetActive(false); 
->SetActive(true);
and

Code: Select all


->GetPosition();
->GetAngle();
->GetLinearVelocity();

->SetTransform(pos, angle);			   
->SetLinearVelocity(speed); 
I think this choice is the fastest of all

Re: Rotation of an object in the other side

Posted: Tue Oct 17, 2017 9:46 am
by iforce2d
Yes, I think that would work ok.