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

More Related Content

Viewers also liked (7)

Transforming c urriculum nov 25b
Transforming c urriculum nov 25bTransforming c urriculum nov 25b
Transforming c urriculum nov 25b
 
Transforming curriculum mar 10
Transforming curriculum mar 10Transforming curriculum mar 10
Transforming curriculum mar 10
 
McRoberts sep 2015pdf2
McRoberts sep 2015pdf2McRoberts sep 2015pdf2
McRoberts sep 2015pdf2
 
Flex Appeal
Flex AppealFlex Appeal
Flex Appeal
 
Windows 8 Apps with HTML & JavaScript
Windows 8 Apps with HTML & JavaScriptWindows 8 Apps with HTML & JavaScript
Windows 8 Apps with HTML & JavaScript
 
Monetizing Mobile Apps
Monetizing Mobile AppsMonetizing Mobile Apps
Monetizing Mobile Apps
 
Build a Flash Game in Under 3KB
Build a Flash Game in Under 3KBBuild a Flash Game in Under 3KB
Build a Flash Game in Under 3KB
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

ActionScript Box2D Quick Start

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