Box2D Forums

It is currently Mon May 20, 2013 7:24 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Feb 18, 2011 9:36 am 
Offline

Joined: Tue Apr 21, 2009 6:12 pm
Posts: 51
Hello all.

I'm working on a game (how surprizing!) which has some complex "see-saw" type objects in it. I'd like to create this object once, then re-use it throughout the game level.

I've tried creating them in a straight MovieClip, which doesn't seem to work. Also also created the object in a new class based off the wck.BodyShape class. This also is problematic. The issue's seem to be - the naming of the components - when i have joints which have the 'targetXname' parameter set, this needs to be in an MC so the names don't clash with other component instances. Really, i'm just confused how to make complex objects into their own component, so i can then re-use it. I'm building them using the timeline, no custom class code.

Any suggestions would be appreciated! Thanks.


Top
 Profile  
 
PostPosted: Fri Feb 18, 2011 1:27 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Yes, you can do this. In the demo, take a look at the "PlatformSwing" symbol in the "SpecialStuff" folder. It's got two distance joints that both have "target2Name" set to "anc" (another joint in that symbol). The "BoxMan" demo uses this platform swing several times. When a joint is built, it looks at it's parent for the symbol named by "target2Name". In most cases, the parent is the World, however the joints in the "PlatformSwing" have that symbol as their parent, not the world, so their is no naming conflict (using "anc" multiple times).

Now lets say you want the joint - within a symbol so it's parent is not the world - reference a joint inside the world (two parents up). Just prefix "target2Name" with a "/". Then it'll use the world as the "root" and look for the symbol there.

You can even set "target2Name" to crazy things like "/someSymbol/otherSymbol/myFarAwayJoint" to traverse the display hierarchy.

So you'll have a see-saw symbol (extends MovieClip, not BodyShape), then in there have your bodies and shapes.


Top
 Profile  
 
PostPosted: Fri Feb 18, 2011 1:43 pm 
Offline

Joined: Tue Apr 21, 2009 6:12 pm
Posts: 51
Ok, that is what i thought should be happening. I'm sure its just me not getting some parameter correct then.

Thanks for making this clear!

Good to know about the target/parent/slash trick - i'd never seen that.

Jos


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 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