Get Joint Type?

I have created a bunch of joints and placed them in a table.  I’d like to be able to go through each joint and do something on it, but I need to be able to detect what type of joint it is.  I looked at the API and didn’t find a way of getting the jointType.  I also found this post. http://forums.coronalabs.com/topic/4590-autocomplete-list-all-functions-and-reserved-words/?hl=%2Bget+%2Bjointtype#entry28071, and it doesn’t appear to have anything, either.  Is there a way to detect what type of joint something has?

Hello,

I don’t believe there’s a way to inherently detect the joint type. Also, since a joint isn’t a Lua table, but rather a “userdata” type, you can’t just add a property like “.thisJointType” onto it. Probably the best solution is to just keep a similarly-ordered table that keeps track of the joint types, and populate it sequentially as you create new joints. So, it would be called something like “gameJointTypeList” and as you add new joints, you add an entry to that table according to the joint type, then later you can look up the same index in that table which relates to the joints table itself.

 

Regards,

Brent Sorrentino

So, basically, I’ll just need to keep two indexes and make sure they stay synched.  That kinda’ stinks, but it’ll have to do for now.  With all the other properties of a joint being accessible, it seems like an oversight to not be able to detect what type of joint something is.  I’ll make this my informal feature request that this be implemented (and file a formal request in the right spot).  Thanks, Brent.

Hello,

I don’t believe there’s a way to inherently detect the joint type. Also, since a joint isn’t a Lua table, but rather a “userdata” type, you can’t just add a property like “.thisJointType” onto it. Probably the best solution is to just keep a similarly-ordered table that keeps track of the joint types, and populate it sequentially as you create new joints. So, it would be called something like “gameJointTypeList” and as you add new joints, you add an entry to that table according to the joint type, then later you can look up the same index in that table which relates to the joints table itself.

 

Regards,

Brent Sorrentino

So, basically, I’ll just need to keep two indexes and make sure they stay synched.  That kinda’ stinks, but it’ll have to do for now.  With all the other properties of a joint being accessible, it seems like an oversight to not be able to detect what type of joint something is.  I’ll make this my informal feature request that this be implemented (and file a formal request in the right spot).  Thanks, Brent.