Unique body names

General discussion about the R.U.B.E editor
Post Reply
metalbass_92
Posts: 18
Joined: Wed Dec 26, 2012 12:27 pm

Unique body names

Post by metalbass_92 »

Hi there,

i've noticed that RUBE doesn't check if the names used for bodies/fixtures and others are unique.
Is there any reason not to? I think it would be better to be able to get only one body with one name.

PS: The forum is small right now, but it should get some more categories (Feature requests, bug notification... etc) before it gets big, right?

Great work with RUBE by the way!
Xavier Arias
Cocos2d-x Game Programmer
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Unique body names

Post by iforce2d »

This is so you can make groups of items. For example you might have a game level with some items that should all be given a certain behavior, eg. maybe trees should wave in the wind. You can select them all and give them the same name, and get them all in a list after loading. If you had to give them all unique names it would be more work.

If you want to only get one body with one name, don't use the same name for more than one body :)

If you find that you are accidentally giving things the same name when you wanted to keep them unique, maybe the item list panel (F6) could help. You can type part of the name in the filter input at the top, to narrow the list down and see if there are duplicates.

Script might be useful to check for duplicates too... eg.
print( getBodies( getSelectedBodies()[0].getName() ).length );
...would print the number of bodies which have the same name as the selected body. This is not so useful right now, but in future when scripts can be bound to a shortcut key it would be a quick way to check if the selected body name will collide with another.
metalbass_92
Posts: 18
Joined: Wed Dec 26, 2012 12:27 pm

Re: Unique body names

Post by metalbass_92 »

Good point, but what if I want a body to be inside a group (example: bodies with name: "Group0") but still want to identify one of them (or each)?

I think we should be able to put bodies into categories (not a string field) and still be able to differentiate them.
If categories are a string field you find yourself writing the same category name n times, which is pretty error prone.

What do you think?
Xavier Arias
Cocos2d-x Game Programmer
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Unique body names

Post by iforce2d »

I think that would require separate properties to manage efficiently. Some people (myself included) have used a system whereby you give things names like "foo=12;bar=34" and parse this after loading, but it's not an ideal solution.

The custom properties I am working on right now will allow you to add extra properties of string or numeric type, whichever suits best. Hopefully this will cover what we are talking about here. Once custom properties are available, the concept of an official 'name' for an item will become less relevant.
Post Reply