# Package com.codename1.gaming.physics

package com.codename1.gaming.physics

2D rigid body physics for Codename One games.

This package provides an idiomatic Codename One wrapper -- `PhysicsWorld`, `PhysicsBody`, `ContactListener` and friends -- around a 2D rigid body simulation. Bodies are linked to `com.codename1.gaming.Sprite`s through `PhysicsLinkable`, and the world is stepped from a `com.codename1.gaming.GameView` update loop. Everything is expressed in screen pixels; the conversion to the simulation's meter based, y-up coordinate system is handled internally (see `PhysicsWorld#setPixelsPerMeter(float)`).

The simulation engine in the sub package `box2d` is a derived work of JBox2D (a Java port of Erin Catto's Box2D), used under the BSD 2-Clause license. The original copyright and license notices are retained in those source files; see the project NOTICE for attribution. Being pure Java, the engine runs on every Codename One platform -- including iOS, where it is translated to C by ParparVM -- with no native code.

- Related Packages
  Package
  Description
  com.codename1.gaming
  Game oriented APIs for Codename One.
- Class
  Description
  BodyType
  The kind of a `PhysicsBody`.
  ContactListener
  Notified when bodies in a `PhysicsWorld` start and stop touching.
  PhysicsBody
  A rigid body in a `PhysicsWorld`, wrapping a shaded Box2D body.
  PhysicsContact
  A contact between two bodies, passed to a `ContactListener`.
  PhysicsJoint
  A constraint that ties two `PhysicsBody` objects together (or a body to the world)
  PhysicsLinkable
  Implemented by anything a `PhysicsBody` can drive -- typically a `com.codename1.gaming.Sprite`.
  PhysicsWorld
  A 2D rigid body physics world, wrapping a shaded Box2D (JBox2D) simulation in an idiomatic Codename One API.