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

  • Class
    Description
    The kind of a PhysicsBody.
    Notified when bodies in a PhysicsWorld start and stop touching.
    A rigid body in a PhysicsWorld, wrapping a shaded Box2D body.
    A contact between two bodies, passed to a ContactListener.
    Implemented by anything a PhysicsBody can drive -- typically a com.codename1.gaming.Sprite.
    A 2D rigid body physics world, wrapping a shaded Box2D (JBox2D) simulation in an idiomatic Codename One API.