Box2D Forums

It is currently Thu May 23, 2013 12:11 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Dec 01, 2011 10:59 pm 
Offline

Joined: Thu Dec 01, 2011 10:50 pm
Posts: 8
Is it possible to make all the movieclips visible on the stage to simulate physics just like addCircle, addBox?

With density:0, so they can collide with moving objects.


Top
 Profile  
 
PostPosted: Sat Dec 03, 2011 10:38 pm 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
Yes, but it would have to be more than just addCircle or addBox. You can make the addCircle and addBox functions and put the physics initialization and stuff in there.


Top
 Profile  
 
PostPosted: Mon Dec 05, 2011 7:20 am 
Offline

Joined: Thu Dec 01, 2011 10:50 pm
Posts: 8
Sorry I'didn't understand what you meant.


Top
 Profile  
 
PostPosted: Wed Dec 07, 2011 2:05 am 
Offline

Joined: Sun Oct 25, 2009 3:28 am
Posts: 242
I just meant that it's not a simple "addCircle" or "addBox" function to apply physics to anything with Box2D because it doesn't have "addCircle" or "addBox" or similarly simple functions. There's a minimum of 4 lines of code to initialize each circle or box (2 line if you reuse shape definitions (what you use to initialize new physics bodies)).

However, since these lines of codes are essentially the same with a few differences (size of shapes, density, etc.), you can put these lines of codes into simpler functions (that you have to make) so it's easier to initialize each movieclip in the stage. But Box2D doesn't provide these simple luxuries right out of the box.

If you haven't already, download the Box2D Flash zip ( http://www.box2dflash.org ) and unzip/extract the files, and open up PhysTest.fla in the Examples folder and test the movie. You can look at the code used in the .as files in the Examples folder.

Also, the density HAS to be more than 0 (zero) unless you want them to be static (non-moving). This is because 0-density doesn't make sense physics-wise in the same way dividing by zero doesn't make sense mathematically. But putting any sort of density more than zero will make them behave normally.


Top
 Profile  
 
PostPosted: Fri Jan 20, 2012 2:08 pm 
Offline

Joined: Sat Aug 01, 2009 12:31 pm
Posts: 17
Location: Poland
yes you can. but you have to loop through all children on the stage, each movieclip needs to have a class (like box) or a component so when you loop you check "if(cuurent_child is box) {physics.addbox(currentchild.x,y,rotation))}"

http://gamedev.michaeljameswilliams.com/2009/06/01/use-flash-ide-as-level-editor/

i made a full level editor like this in flash ide.


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: No registered users and 3 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