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.Sprites 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.

Types

enum BodyTypeThe kind of a PhysicsBody.
interface ContactListenerNotified when bodies in a PhysicsWorld start and stop touching.
class PhysicsBodyA rigid body in a PhysicsWorld, wrapping a shaded Box2D body.
class PhysicsContactA contact between two bodies, passed to a ContactListener.
class PhysicsJointA constraint that ties two PhysicsBody objects together (or a body to the world) – a pin, a slider, a weld, a spring, a drag handle.
interface PhysicsLinkableImplemented by anything a PhysicsBody can drive – typically a com.codename1.gaming.Sprite.
class PhysicsWorldA 2D rigid body physics world, wrapping a shaded Box2D (JBox2D) simulation in an idiomatic Codename One API.