Box2D Forums

It is currently Tue May 21, 2013 11:12 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Jul 29, 2012 4:04 am 
Offline

Joined: Fri Jul 29, 2011 3:09 am
Posts: 16
Hi.
i've searched a lot and tryied a lot of possiblities but i couldn get it to work.

please look at below code.

(i Use Flash Builder + wck)

my hero collide to a box, box name is "tb";

now it should add a "distance" joint witch connect them together:

Code:
var pJoint1:Joint = new Joint();
      pJoint1.type = "None"; // i also tried Revolute Joint
      pJoint1.x = x;
      pJoint1.y = y;
      pJoint1.bodyShape1 =  tb as BodyShape; // i also tried target1Object
      pJoint1.bodyShape2 =  hro as BodyShape;
      addChild(pJoint1);

      var pJoint2:Joint = new Joint();
      pJoint2.type = "Distance";
      pJoint2.bodyShape1 =  tb as BodyShape;
      pJoint2.bodyShape2 =  hro as BodyShape;
      addChild(pJoint1);
      addChild(pJoint2);


but i get object AlchemyExit error:

Code:
[object AlchemyExit]
   at Function/<anonymous>()
   at Function/<anonymous>()
   at Box2DAS.Dynamics.Joints::b2Joint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\Joints\b2Joint.as:21]
   at Box2DAS.Dynamics.Joints::b2DistanceJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\Joints\b2DistanceJoint.as:20]
   at wck::Joint/createDistanceJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:653]
   at wck::Joint/createJoint()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:536]
   at wck::Joint/create()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\Joint.as:391]
   at misc::Entity/ensureCreated()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\misc\Entity.as:50]
   at misc::Entity/handleAddedToStage()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\misc\Entity.as:100]
   at flash.display::DisplayObjectContainer/addChild()
   at MyWorld/pushObj()[D:\Adobe Flash Builder\Rebox\src\MyWorld.as:652]
   at Hero/handleContact()[D:\Adobe Flash Builder\Rebox\src\Hero.as:81]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at Box2DAS.Common::b2EventDispatcher/dispatchEvent()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Common\b2EventDispatcher.as:27]
   at Box2DAS.Dynamics::b2ContactListener/ContactDispatch()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2ContactListener.as:64]
   at Box2DAS.Dynamics::b2ContactListener/BeginContact()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2ContactListener.as:31]
   at Box2DAS.Dynamics::b2World/BeginContact()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:346]
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at global/AS3_CallTS()
   at Function/http://adobe.com/AS3/2006/builtin::apply()
   at Function/<anonymous>()
   at cmodule.Box2D::FSM__ZN13WorldListener12BeginContactEP9b2Contact/work()
   at Function/<anonymous>()
   at Function/<anonymous>()
   at Box2DAS.Dynamics::b2World/HandleStep()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:162]
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at Box2DAS.Common::b2EventDispatcher/dispatchEvent()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Common\b2EventDispatcher.as:27]
   at Box2DAS.Dynamics::b2World/Step()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\Box2DAS\Dynamics\b2World.as:158]
   at wck::World/step()[D:\Adobe Flash Builder\Rebox\src\Libs\jesses-wck-5945c35\wck\World.as:198]



tanks for replyes.... i should get this to work as soon as possible...


Top
 Profile  
 
PostPosted: Sun Jul 29, 2012 11:59 am 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
I use Flash IDE but my code is pretty much the same.

j1 = new Joint();
j1.type = "Revolute";
j1.bodyShape1 = carBody;
j1.bodyShape2 = wheel1;
j1.x = wheel1.x;
j1.y = wheel1.y;
Util.addChildAtPos(MyWorld, j1, wheel1);

If you are using all of the code that you mentioned. Why are you adding two joints? One should be enough.

pJoint1.type = "None";
That is probably not a good idea.

Other than that, I'm not sure.


Top
 Profile  
 
PostPosted: Sun Jul 29, 2012 12:26 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Are you trying to create the joint mid-timestep? That's the most common error. You have to wait until the timestep ends to create joints / bodies.


Top
 Profile  
 
PostPosted: Sun Jul 29, 2012 11:28 pm 
Offline

Joined: Fri Jul 29, 2011 3:09 am
Posts: 16
Taaaanks A Lot!
It works like a charm now!

it solved by adding
Code:
_world.doOutsideTimeStep(addJointsFunc);



tanQ veryyyyyyy Much ! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group