Packagecitrus.physics.box2d
Classpublic class Box2D
InheritanceBox2D Inheritance APhysicsEngine Inheritance CitrusObject Inheritance Object
Implements ISpriteView

This is a simple wrapper class that allows you to add a Box2D world to your game's state. Add an instance of this class to your State before you create any physics bodies. It will need to exist first, or your physics bodies will throw an error when they try to create themselves.



Public Properties
 PropertyDefined By
 Inheritedanimation : String
[read-only]
APhysicsEngine
 Inheritedart : ICitrusArt
[read-only]
APhysicsEngine
 InheriteddebugView : IDebugView
[read-only] Shortcut to the debugView use to change the debug drawer's flags with debugView.debugMode() or access it directly through debugView.debugDrawer.
APhysicsEngine
 Inheriteddepth : Number
[read-only]
APhysicsEngine
  gravity : b2Vec2
Change the gravity of the world.
Box2D
 Inheritedgroup : uint
APhysicsEngine
 Inheritedheight : Number
[read-only]
APhysicsEngine
 InheritedhideParamWarnings : Boolean = false
[static]
CitrusObject
 InheritedID : uint
[read-only]
CitrusObject
 Inheritedinverted : Boolean
[read-only]
APhysicsEngine
 Inheritedkill : Boolean = false
Set it to true if you want to remove, clean and destroy the object.
CitrusObject
 Inheritedname : String
A name to identify easily an objet.
CitrusObject
 InheritedoffsetX : Number
[read-only]
APhysicsEngine
 InheritedoffsetY : Number
[read-only]
APhysicsEngine
 InheritedparallaxX : Number
[read-only]
APhysicsEngine
 InheritedparallaxY : Number
[read-only]
APhysicsEngine
  positionIterations : uint = 8
ositionIterations for the position constraint solver.
Box2D
 InheritedrealDebugView : *
[read-only]
APhysicsEngine
 Inheritedregistration : String
[read-only]
APhysicsEngine
 Inheritedrotation : Number
[read-only]
APhysicsEngine
  scale : Number
[read-only] This is hard to grasp, but Box2D does not use pixels for its physics values.
Box2D
  timeStep : Number
timeStep the amount of time to simulate, this should not vary.
Box2D
 Inheritedtouchable : Boolean
APhysicsEngine
 Inheritedtype : String = classicObject
Added to the CE's render list via the State and the add method.
CitrusObject
 InheritedupdateCallEnabled : Boolean = false
This property prevent the update method to be called by the enter frame, it will save performances.
CitrusObject
 Inheritedvelocity : Array
[read-only]
APhysicsEngine
  velocityIterations : uint = 8
velocityIterations for the velocity constraint solver.
Box2D
 Inheritedview : *
APhysicsEngine
 Inheritedvisible : Boolean
APhysicsEngine
 Inheritedwidth : Number
[read-only]
APhysicsEngine
  world : b2World
[read-only] Gets a reference to the actual Box2D world object.
Box2D
 Inheritedx : Number
[read-only]
APhysicsEngine
 Inheritedy : Number
[read-only]
APhysicsEngine
 Inheritedz : Number
[read-only]
APhysicsEngine
Protected Properties
 PropertyDefined By
 Inherited_art : ICitrusArt
APhysicsEngine
 Inherited_ce : CitrusEngine
CitrusObject
 Inherited_group : uint = 1
APhysicsEngine
 Inherited_initialized : Boolean = false
CitrusObject
 Inherited_params : Object
CitrusObject
 Inherited_realDebugView : *
APhysicsEngine
 Inherited_timeDelta : Number
The time elasped between two update call.
CitrusObject
 Inherited_touchable : Boolean = false
APhysicsEngine
 Inherited_view : *
APhysicsEngine
 Inherited_visible : Boolean = false
APhysicsEngine
Public Methods
 MethodDefined By
  
Box2D(name:String, params:Object = null)
Creates and initializes a Box2D world.
Box2D
  
destroy():void
[override]
Box2D
 Inherited
APhysicsEngine
 Inherited
APhysicsEngine
 Inherited
handleArtReady(citrusArt:ICitrusArt):void
APhysicsEngine
  
initialize(poolObjectParams:Object = null):void
[override]
Box2D
 Inherited
setParams(object:Object, params:Object):void
The initialize method usually calls this.
CitrusObject
 Inherited
toString():String
CitrusObject
  
update(timeDelta:Number):void
[override] This is where the time step of the physics world occurs.
Box2D
Property Detail
gravityproperty
gravity:b2Vec2

Change the gravity of the world.


Implementation
    public function get gravity():b2Vec2
    public function set gravity(value:b2Vec2):void
positionIterationsproperty 
public var positionIterations:uint = 8

ositionIterations for the position constraint solver.

scaleproperty 
scale:Number  [read-only]

This is hard to grasp, but Box2D does not use pixels for its physics values. Cutely, it uses meters and forces us to convert those meter values to pixels by multiplying by 30. If you don't multiple Box2D values by 30, your objects will look very small and will appear to move very slowly, if at all. This is a reference to the scale number by which you must multiply your values to properly display physics objects.


Implementation
    public function get scale():Number
timeStepproperty 
public var timeStep:Number

timeStep the amount of time to simulate, this should not vary.

velocityIterationsproperty 
public var velocityIterations:uint = 8

velocityIterations for the velocity constraint solver.

worldproperty 
world:b2World  [read-only]

Gets a reference to the actual Box2D world object.


Implementation
    public function get world():b2World
Constructor Detail
Box2D()Constructor
public function Box2D(name:String, params:Object = null)

Creates and initializes a Box2D world.

Parameters
name:String
 
params:Object (default = null)
Method Detail
destroy()method
override public function destroy():void

initialize()method 
override public function initialize(poolObjectParams:Object = null):void

Parameters

poolObjectParams:Object (default = null)

update()method 
override public function update(timeDelta:Number):void

This is where the time step of the physics world occurs.

Parameters

timeDelta:Number