Box2D Forums

It is currently Tue May 21, 2013 12:47 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Apr 07, 2011 1:35 am 
Offline

Joined: Thu Mar 17, 2011 2:03 am
Posts: 41
What are the best practices for segmenting WCK levels?


Top
 Profile  
 
PostPosted: Thu Apr 07, 2011 7:38 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
Do you mean segmenting a single level, or laying out multiple levels?

I've recently realized I'm going to have to segment my individual levels. They've gotten to large. I would like to hear if anyone else has solved this.

The approach I'm thinking of taking is adding a component property called "region" where you can specify one or more regions for each BodyShape / Joint. Then the world would have an "activateRegion" method that would enable one region and disable all others via the "active" property of b2Body. The idea is non-active regions should be visible but not doing anything in Box2D.

Another approach is to keyframe your level so that parts disappear / appear sequentially as the player moves through it. "gotoAndStop" would be used to move through regions. This would mean parts of the level would not be visible all the time (ok for a simple left to right level). Probably problematic if a dynamic body moves into the "void" of a non-active region though.

Another idea I've been considering is having an AABB query around the player on every frame that disables non visible objects (via "active" property). I think this might be problematic though if active and non-active bodies are touching at the AABB boundary.



If you mean switching between multiple levels... just detach the old, attach the new ("addChild"). I wouldn't lay them out in frames like the demos.


Top
 Profile  
 
PostPosted: Thu Apr 07, 2011 10:43 pm 
Offline

Joined: Thu Mar 17, 2011 2:03 am
Posts: 41
I was thinking of using a new scene for each level.. but yes addChild on levels might make more sense.. Would you addChild level to the entire world (new WCK World as level each time), or addChild level within the world?


Top
 Profile  
 
PostPosted: Thu Apr 07, 2011 11:45 pm 
Offline

Joined: Tue Nov 09, 2010 1:26 am
Posts: 92
What size are your levels mayo? I have some that I think are around 20k wide and they work fine for the most part.

One thing we've noticed on a few occasions is there's a certain absolute x value where Box2d things stop working. To solve this, we take the instance on the timeline for that world and move it over to the left, lol.

What do you feel is the upside to the addChild vs. having them on the timeline? I know one advantage to having them on the timeline at all is that when you get levels as big as the ones we've got, you can work on them at 25% scale (on a guided layer so they don't publish at that scale) and tweak them. If you drilled into a library instance where it operates at it's 100%, you wouldn't be able to do that at all.

I'm in an all out war vs. creative trying to wrangle their intense visual stuff. Trying not to sweat it, but it's definitely on my shoulders and they just continually add detail. Guess that's why I'm up at 3am working on this stuff. Can't sleep when I know how slow some of the levels are running right now, :cry:


Top
 Profile  
 
PostPosted: Fri Apr 08, 2011 6:30 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
ina: I would organize your levels into separate Worlds. And there probably is nothing wrong with using scenes / keyframes. I was just thinking about how you can right click Flash and "advance" the frame for the main timeline. So just avoid using the root timeline.

burtonposey: I'm building up to the max Flash will let me @ 100% (around 7000x7000). I implemented the regions solution last night - it works surprisingly well. I was expecting a short delay when Box2D deactivated / activated a bunch of bodies but there is none. The regions have to be manually managed via code (I trigger them with sensors), but it seems worth the hassle. It doesn't handle dynamic non-player bodies changing regions though (I prevent this by creating "tunnels" between regions only the player small enough to go through). I seems your only problem is graphics though so I guess this won't help, lol.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Exabot [Bot] and 0 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