Variable name of body?

Official forum for the Chipmunk2D Physics Library.
Post Reply
knutselman
Posts: 3
Joined: Fri Jul 22, 2011 9:54 am
Contact:

Variable name of body?

Post by knutselman »

Hello,

I have a program that creates around 2000 bodies, but I don't want them to have the same name.
Now, they're all named "body", but I want them to get a name from "1" to "2000". I have a string with the number (it changes every time the create script is runned), but I can't create a body with the name in the string variable.

Does anyone know how?

Thank you
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Variable name of body?

Post by slembcke »

You want to use an array.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
knutselman
Posts: 3
Joined: Fri Jul 22, 2011 9:54 am
Contact:

Re: Variable name of body?

Post by knutselman »

Could you post a code example?

I don't get it why I have to use an array???

Thank you
User avatar
AmIMeYet
Posts: 6
Joined: Mon Aug 15, 2011 8:32 am
Contact:

Re: Variable name of body?

Post by AmIMeYet »

knutselman: Let me put it this way: why do you want to give your bodies a name? And how do you get/set the body names?

What slembcke means is that you can place your bodies in an array, and use that to reference specific bodies (i.e. instead of using names, you use the array index.)
Post Reply

Who is online

Users browsing this forum: Heise IT-Markt [Crawler] and 7 guests