Daniel Cohen talks shop
Posts tagged framework
Announcing Box2D Flex framework
21 year ago
Prefix
In a previous post demonstrating box2d integration with flex I made a promise (mainly to myself) to share the demo code. When I started to review with sharing in mind it looked cumbersome and overly verbose. So I started cranking on it fixing and straightening the code & architecture and step by step I realized that I’m creating a small Integration layer rather then a POC.
Announcing Box2DFlex
Box2DFlex framework allows you easely integrate box2d into flex framework using mxml. The framewok helps easy integration with flex and exposes box2d world for advanced manipulation.
- extends SkinnableContainer uses flex component lifecycle model
- uses regular MXML and AS flex components
- supports complex shaped flex components (convex and concave) conversion to b2d shapes.
- allows multiple worlds side by side
Getting Started
In order to play with Box2dFlex you will need flash builder 4 and Box2DFlex source which is hosted on GitHub.
and in four simple steps you should
- download the source code
- inport the Box2DFlex and Demos projects into flash builder 4
- compile
- Play with the eamples in Box2Demos project
Building Your Own b2d World
- download the framework
- create a new project
- add refrence to <Box2DFlex dir>/Box2dFlexLib/bin/Box2DFlexLib.swc
- in your MXML add a new SkinnablePhysicsContainer
- set the container’s yGravity property to 10 and autoStartPhysicsEngine to true (yGravity=”10 autoStartPhysicsEngine=”true”)
- if you want your world to contains walls use setBoundries=”true” attribute
- place a button inside SkinnablePhysicsContainer and set it’s properties (width / height / label)
- run the project