zerk.game.engine.physics Class
Physics engine interface
Box2dWeb implementation.
Item Index
Methods
- _addContactListener
- _cleanup
- _createBody
- _createFixture
- _createFixtureCircle
- _createFixturePolygon
- _createFixtureRectangle
- _createJoint
- _createJointDistance
- _createJointMouse
- _createJointRevolute
- _destroyBody
- _destroyJoint
- _getBodyAtMouseCallback
- _log
- _onContactBegin
- _onContactEnd
- _onContactPostSolve
- _onContactPreSolve
- _processMouseJoint
- createPhysics
- dumpPhysicsData
- fireEvent
- getBodyAtMouse
- getEntitiesInArea
- init
- on
- removePhysics
- scheduleDestroyBody
- scheduleDestroyJoint
- syncEntityPhysics
- tick
- un
Properties
Methods
_addContactListener
()
protected
Registers the contact listener event handlers
_cleanup
()
protected
Destroy bodies and joints schedules to be removed from the world
_createBody
-
entity
-
body
Creates a body
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
Returns:
_createFixture
-
entity
-
body
-
fixture
Delegate method for fixture creation
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
-
fixture
zerk.game.engine.physics.fixtureFixture
Returns:
_createFixtureCircle
-
entity
-
body
-
fixture
Creates a circle shaped fixture
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
-
fixture
zerk.game.engine.physics.fixtureFixture
Returns:
_createFixturePolygon
-
entity
-
body
-
fixture
Creates a polygon shaped fixture
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
-
fixture
zerk.game.engine.physics.fixtureFixture
Returns:
_createFixtureRectangle
-
entity
-
body
-
fixture
Creates a rectangle shaped fixture
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
-
fixture
zerk.game.engine.physics.fixtureFixture
Returns:
_createJoint
-
entity
-
joint
Delgate method for joint creation
Parameters:
-
entity
zerk.game.engine.entityEntity
-
joint
zerk.game.engine.physics.jointJoint
Returns:
_createJointDistance
-
entity
-
joint
Creates a distance joint
Parameters:
-
entity
zerk.game.engine.entityEntity
-
joint
zerk.game.engine.physics.jointJoint
Returns:
_createJointMouse
-
body
-
targetX
-
targetY
Creates a mouse joint
Parameters:
-
body
ObjectBox2dWeb body
-
targetX
FloatHorizontal position
-
targetY
FloatVertical position
Returns:
_createJointRevolute
-
entity
-
joint
Creates a revolute join
Parameters:
-
entity
zerk.game.engine.entityEntity
-
joint
zerk.game.engine.physics.jointJoint
Returns:
_destroyBody
-
entity
-
body
Destroys a body
Parameters:
-
entity
zerk.game.engine.entityEntity
-
body
zerk.game.engine.physics.bodyBody
_destroyJoint
-
entity
-
joint
Destroys a joint
Parameters:
-
entity
zerk.game.engine.entityEntity
-
joint
zerk.game.engine.physics.jointJoint
_getBodyAtMouseCallback
-
fixture
Callbak method for internal processing of getBodyAtMouse
Parameters:
-
fixture
ObjectBox2D fixture
Returns:
_log
-
msg
Local log method
Parameters:
-
msg
StringLog message
_onContactBegin
-
contact
Contact begin event handler
Parameters:
-
contact
ObjectContact information
_onContactEnd
-
contact
Contact end event handler
Parameters:
-
contact
ObjectContact information
_onContactPostSolve
-
contact
-
impulse
Contact post solve event handler
Parameters:
-
contact
ObjectContact information
-
impulse
ObjectImpulse information
_onContactPreSolve
-
contact
-
oldManifold
Contact pre solve event handler
Parameters:
-
contact
ObjectContact information
-
oldManifold
Object
_processMouseJoint
()
protected
Process mouse joint
createPhysics
-
entity
Create the physics engine representation for an entity
Parameters:
-
entity
zerk.game.engine.entityEntity
dumpPhysicsData
()
Dumps elements currently contained in physics simulation to console
fireEvent
-
event
Fire event
Parameters:
-
event
StringEvent name
Returns:
getBodyAtMouse
()
Object
Returns body at current cursor position if present
Returns:
getEntitiesInArea
-
x1
-
y1
-
x2
-
y2
Returns an array of entities inside given area
Parameters:
-
x1
Float -
y1
Float -
x2
Float -
y2
Float
Returns:
on
-
event
-
callback
-
scope
Register event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback function. Return false to cancel event bubble.
-
scope
ObjectScope to be used in callback function
removePhysics
-
entity
Removes the physics engine representation for an entity
Parameters:
-
entity
zerk.game.engine.entityEntity
scheduleDestroyBody
-
entity
-
body
Schedules a body to be destroyed after current simulation tick
Parameters:
-
entity
zerk.game.engine.entity -
body
zerk.game.engine.physics.body
scheduleDestroyJoint
-
entity
-
body
Schedules a join to be destroyed after current simulation tick
Parameters:
-
entity
zerk.game.engine.entity -
body
zerk.game.engine.physics.join
syncEntityPhysics
-
entity
Synchronize the physic simulation properties of an entity
Parameters:
-
entity
zerk.game.engine.entityEntity
tick
()
Physics engine tick
un
-
event
-
callback
Unregister event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback function
Returns:
Properties
__destroyJointList
Array
protected
List of joints to be destroyed after current simulation tick
_b2AABB
Object
protected
Shortcut for Box2D.Collision.b2AABB
_b2Body
Object
protected
Shortcut for Box2D.Dynamics.b2Body
_b2BodyDef
Object
protected
Shortcut for Box2D.Dynamics.b2BodyDef
_b2CircleShape
Object
protected
Shortcut for Box2D.Collision.Shapes.b2CircleShape
_b2ContactListener
Object
protected
Shortcut for Box2D.Dynamics.b2ContactListener
_b2DebugDraw
Object
protected
Shortcut for Box2D.Dynamics.b2DebugDraw
_b2DistanceJointDef
Object
protected
Shortcut for Box2D.Dynamics.Joints.b2DistanceJointDef
_b2FixtureDef
Object
protected
Shortcut for Box2D.Dynamics.b2FixtureDef
_b2MouseJointDef
Object
protected
Shortcut for Box2D.Dynamics.Joints.b2MouseJointDef
_b2PolygonShape
Object
protected
Shortcut for Box2D.Collision.Shapes.b2PolygonShape
_b2RevoluteJointDef
Object
protected
Shortcut for Box2D.Dynamics.Joints.b2RevoluteJointDef
_b2Vec2
Object
protected
Shortcut for Box2D.Common.Math.b2Vec2
_b2World
Object
protected
Shortcut for Box2D.Dynamics.b2World
_config
Object
protected
Physics configuration
_destroyBodyList
Array
protected
List of bodies to be destroyed after current simulation tick
_eventListeners
Array
protected
List of event handlers
_mouseJoint
Object
protected
Handle for the mouse joint
_mouseJointVec
Object
protected
Stores a vector for the mouse joint function
_selectedBody
Object
protected
Stores the last selected body
_world
Box2D.Dynamics.b2World
protected
Box2D world
Events
contactbegin
Fires when two fixtures start colliding
Event Payload:
-
sourceFixture
zerk.game.engine.physics.fixtureSource fixture
-
targetFixture
zerk.game.engine.physics.fixtureTarget fixture
contactend
Fires when two fixtures stop colliding
Event Payload:
-
sourceFixture
zerk.game.engine.physics.fixtureSource fixture
-
targetFixture
zerk.game.engine.physics.fixtureTarget fixture
contactpostsolve
Fires before two fixtures start colliding
Event Payload:
-
sourceFixture
zerk.game.engine.physics.fixtureSource fixture
-
targetFixture
zerk.game.engine.physics.fixtureTarget fixture
-
impulse
Object