box 2d modification help

Previous topic - Next topic


hi im doing alitle mod on the box2d source and im in a little problem:
im trying to add userdata to the def
im doing this:

FUNCTION b_CreateBox1: mass, friction, restitution, x, y, w, h ,art$

   b2BodyDef def;

   char *ss=art_Str;

   b2Body* pBody = bWorld->CreateBody( &def );

   b2PolygonDef poly;
      if(mass>0.0) poly.density = mass;
      poly.friction = friction;
      poly.restitution = restitution;
      poly.SetAsBox(w*.5, h*.5);
      pBody->CreateShape( &poly);
      if(mass>0.0) pBody->SetMassFromShapes();

   return b_NewObject(pBody, bBody);

the art$ is a string

im trying to get it out when the object contat but im getting a weird varlues

anyone has any input?


You could try :

Code (glbasic) Select


Kitty Hello

baaaad! You store a pointer, but the memory it pointed to might change!
You can't do that. You can keep a global string list and store the index here -that's all.