Box2D AS3 Quick Start<br />Chris Black<br />
What is Box2D for Flash?<br />“Box2DFlashAS3 is an open source port of Erin Catto's powerful c++ physics library Box2D.” <...
Uses of Box2D<br />Games, physics demos and… games.<br />Very little practical application outside of games.<br />Clients ...
AS3 Physics Comparison<br />For a great comparison on physics engines available for Flash check out this post:<br />http:/...
Box2D vs Flash CS5<br />Flash CS5 has a built in engine for creating STATIC demos. <br />Box2D should be used when user in...
Getting Started<br />Grab the quick start demo from Google Code<br />Starting from scratch:<br />Add the SWC or download B...
Constants<br />public static const PHYS_SCALE:Number = 10;<br />// Number of pixels in a Meter.<br />public static const T...
Create a World<br />
2D Object VO<br />
Create an Object<br />
Add Object to the World<br />
Demo<br />Basketball Demo<br />Car Demo<br />
Box2D for Android<br />GPU Acceleration<br />CacheAsBitmapMatrix<br />30 fps on the Nexus One<br />Video demo on Nexus One...
Box2D for iOS<br />Box2D doesn’t perform well using the iOS exporter within Flash CS5.<br />This might improve with future...
Box2D for JavaScript<br />Older version compared to Flash<br />Doesn’t perform as well on a PC<br />Takes longer to code<b...
Now what?<br />Download<br />http://box2dflash.sourceforge.net/<br />http://box2d-js.sourceforge.net/<br />Learn<br />http...
Upcoming SlideShare
Loading in …5
×

ActionScript Box2D Quick Start

7,565 views

Published on

Box2D is the most powerful and widely used physics engine for Flash. It allows developers to quickly create dynamic, life like, environments for games and applications. In this session we'll cover everything you need to get started with the latest version of Box2D. Learn how to create a 2D world, add objects and apply forces. All source code for the demo will be provided and we'll finish with an example of Box2D running on the Nexus One with Adobe AIR!

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
7,565
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
63
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

ActionScript Box2D Quick Start

  1. 1. Box2D AS3 Quick Start<br />Chris Black<br />
  2. 2. What is Box2D for Flash?<br />“Box2DFlashAS3 is an open source port of Erin Catto's powerful c++ physics library Box2D.” <br />–Box2DFlash<br />Current version 2.0.1 Flash and 1.4.3.1 for JavaScript.<br />Box2D can be used to quickly add ‘real life’ physics to your Flash / Flex projects.<br />
  3. 3. Uses of Box2D<br />Games, physics demos and… games.<br />Very little practical application outside of games.<br />Clients looking for animation often feel Box2D looks too ‘real.’<br />
  4. 4. AS3 Physics Comparison<br />For a great comparison on physics engines available for Flash check out this post:<br />http://www.emanueleferonato.com/2008/04/24/flash-physics-engines-galore/<br />
  5. 5. Box2D vs Flash CS5<br />Flash CS5 has a built in engine for creating STATIC demos. <br />Box2D should be used when user interaction is required for DYNAMIC apps.<br />If your animation changes based on user interaction, use Box2D. <br />
  6. 6. Getting Started<br />Grab the quick start demo from Google Code<br />Starting from scratch:<br />Add the SWC or download Box2D source<br />Set up your constants<br />Create a world with boundries<br />Add objects to the world<br />
  7. 7. Constants<br />public static const PHYS_SCALE:Number = 10;<br />// Number of pixels in a Meter.<br />public static const TIMESTEP:Number = 1.0 / 15.0;<br />// How many physical calculations per timestep. Usually 1 / 15 or 1 / 60.<br />public static const ITERATIONS:Number = 10.0;<br />// The suggested iteration count is 10.<br />
  8. 8. Create a World<br />
  9. 9. 2D Object VO<br />
  10. 10. Create an Object<br />
  11. 11. Add Object to the World<br />
  12. 12. Demo<br />Basketball Demo<br />Car Demo<br />
  13. 13. Box2D for Android<br />GPU Acceleration<br />CacheAsBitmapMatrix<br />30 fps on the Nexus One<br />Video demo on Nexus One<br />
  14. 14. Box2D for iOS<br />Box2D doesn’t perform well using the iOS exporter within Flash CS5.<br />This might improve with future iterations but for now use native Objective-C for iOS apps that require physics.<br />
  15. 15. Box2D for JavaScript<br />Older version compared to Flash<br />Doesn’t perform as well on a PC<br />Takes longer to code<br />Worth trying out but needs some major updates before it will compare to Flash.<br />
  16. 16. Now what?<br />Download<br />http://box2dflash.sourceforge.net/<br />http://box2d-js.sourceforge.net/<br />Learn<br />http://www.emanueleferonato.com/category/box2d/<br />http://www.blackcj.com/blog/tag/box2d/<br />

×