Class WorldObserver

java.lang.Object
net.dermetfan.gdx.physics.box2d.WorldObserver

public class WorldObserver
extends java.lang.Object
Notifies a WorldObserver.Listener of changes in the world. Does NOT work on HTML5!
Since:
0.6.0
  • Constructor Details

    • WorldObserver

      public WorldObserver()
      creates a new WorldObserver with no listener
    • WorldObserver

      public WorldObserver​(WorldObserver.Listener listener)
      Parameters:
      listener - the listener
  • Method Details

    • update

      public void update​(com.badlogic.gdx.physics.box2d.World world, float step)
      Parameters:
      world - Ideally always the same World because its identity is not checked. Passing in another world instance will cause all differences between the two worlds to be processed.
      step - the time the world was last stepped with
    • getBodyChange

      public WorldObserver.BodyChange getBodyChange​(int hash)
      Parameters:
      hash - the hash of the Body (computed via Box2DUtils#hashCode(Body)) which associated BodyChange to return
      Returns:
      the BodyChange from bodyChanges currently used for the Body with the given hash, or null if not found
    • getFixtureChange

      public WorldObserver.FixtureChange getFixtureChange​(int hash)
      Parameters:
      hash - the hash of the Fixture (computed via Box2DUtils#hashCode(Fixture)) which associated FixtureChange to return
      Returns:
      the FixtureChange from fixtureChanges currently used for the Fixture with the given hash, or null if not found
    • getJointChange

      public WorldObserver.JointChange getJointChange​(com.badlogic.gdx.physics.box2d.Joint joint)
      Parameters:
      joint - the joint which associated JointChange to return
      Returns:
      the JointChange from jointChanges currently used for the given Joint
    • getWorldChange

      public WorldObserver.WorldChange getWorldChange()
      Returns:
      the worldChange
    • getListener

      public WorldObserver.Listener getListener()
      Returns:
      the listener
    • setListener

      public void setListener​(WorldObserver.Listener listener)
      Parameters:
      listener - the listener to set