Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/openfl/box2d
Haxe port of Box2D, a popular rigid-body 2D physics engine
https://github.com/openfl/box2d
box2d haxe openfl physics physics-engine
Last synced: 3 days ago
JSON representation
Haxe port of Box2D, a popular rigid-body 2D physics engine
- Host: GitHub
- URL: https://github.com/openfl/box2d
- Owner: openfl
- License: other
- Created: 2012-01-17T21:47:41.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2024-09-03T23:01:30.000Z (5 months ago)
- Last Synced: 2024-10-30T00:54:59.295Z (3 months ago)
- Topics: box2d, haxe, openfl, physics, physics-engine
- Language: Haxe
- Homepage:
- Size: 320 KB
- Stars: 96
- Watchers: 9
- Forks: 28
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE.md) [![Haxelib Version](https://img.shields.io/github/tag/openfl/box2d.svg?style=flat&label=haxelib)](http://lib.haxe.org/p/box2d)
Box2D
=====The Box2D rigid-body 2D physics engine, ported to Haxe from the Box2DFlash port by Boris the Brave.
The syntax has been updated to follow the standard Haxe convention, for example:
**ActionScript**
```as3
var world:b2World = new b2World (new b2Vec2 (0, 10.0), true);
var worldScale:int = 30;
var body:b2BodyDef = new b2BodyDef ();
body.position.Set (250 / worldScale, 200 / worldScale);
body.type = b2Body.b2_dynamicBody;
var circle:b2CircleShape = new b2CircleShape (10 / worldScale);
var fixture:b2FixtureDef = new b2FixtureDef ();
fixture.shape = circle;
player = world.CreateBody (body);
player.CreateFixture (fixture);
```The above ActionScript code would be written like this in Haxe:
**Haxe**
```haxe
var world = new B2World (new B2Vec2 (0, 10.0), true);
var worldScale = 30;
var body = new B2BodyDef ();
body.position.set (250 / worldScale, 200 / worldScale);
body.type = DYNAMIC_BODY;
var circle = new B2CircleShape (10 / worldScale);
var fixture = new B2FixtureDef ();
fixture.shape = circle;
player = world.createBody (body);
player.createFixture (fixture);
```Installation
============You can easily install Box2D using haxelib:
haxelib install box2d
To add it to a Lime or OpenFL project, add this to your project file:
Development Builds
==================Clone the Box2D repository:
git clone https://github.com/openfl/box2d
Tell haxelib where your development copy of Box2D is installed:
haxelib dev box2d box2d
To return to release builds:
haxelib dev box2d