WCK Documentation
From Box2D Wiki
Contents |
is this a good place?
I am planning to help MayoButter document WCK and i feel like this would be an appropriate location to store the documentation
as discussed here:
http://www.box2d.org/forum/viewtopic.php?f=8&t=4105&p=21026#p21026
-SketchBookGames
What is WCK
World Construction Kit (WCK) is a game engine wrapped around Box2dFlash
WCK uses alchemy to port the C++ version of Box2D to AS3.
currently WCK supports:
- Flash CS4
- Map Building on the stage of the Flash IDE
- Action Script 3
- Box2D version 2.1
links:
it is also possible to use the alchemy port of Box2D w/o using WCK.
FAQ:
What version of the Flash Player do i need?
You need to target Flash Player 10 at a minimum.
Note: Flex Builder 3 users need to update the Flex SDK. This is awkward in Flex Builder 3 due to the forced HTML wrapper issue. Instead, aquire Flash Builder 4 (currently Beta 2).
When i try to run Demo.swf from the WCK repository, i see looping frames.
It is important to note that your Flash CS4 software must to be upto date before using WCK. To update, goto Help > Updates... from inside the Flash IDE.
Getting started, setting up a new FLA
http://wiki.github.com/jesses/wck/
Bodies and Shapes
the wck.BodyShape class serves as both bodies and shapes.
if you have a body that only needs one shape, you could set the base class to shapes.Box (which in turn extends wck.BodyShape) for example. and not need a seperate symbol for the body.
many of the demo's are setup this way.
however you can still achieve a more specific shape by having a body, and several shapes inside of it.
your body's base class would then extend wck.BodyShape, and your shapes would extend a specific shape class.
in this way you can also separate your bodies art assets from its physics shapes, where as when the body and shape are one, your art asset becomes part of the parameters of the shape calculations.
Contacts
to listen for contacts,
see Demo/BoxMan.as in the source.
contact dispatching is off by default because alchemy calls back and forth are a bit heavy.
event types (should be the same as Box2D 2.1) found in Box2DAS.Dynamics.ContactEvent.as
public static var BEGIN_CONTACT:String = 'onBeginContact';
public static var END_CONTACT:String = 'onEndContact';
public static var PRE_SOLVE:String = 'onPreSolve';
public static var POST_SOLVE:String = 'onPostSolve';
physics properties and component inspector
- active: ? unknown, if false probably removes event listeners until its set to active, a good example would be something off screen.
- allowDragging: if true a mouse listener and joint will be setup to allow physics dragging by mouse.
- angularDamping: slows rotation, generally 0.0 to 1.0, but higher numbers are applicable.
- angularVelocity: starting rotation speed.
- applyGravity: if true gravity will effect this object.
- autoSleep: if true this object will become inactive when at rest for a while. reducing its weight on the processor.
- awake: if true, the body starts out awake, if false it will start out asleep. (sleeping bodies don't even fall until they are woke up, like an apple in a tree)
- bullet: if true, run extra collision processes to keep this object from going through other objects, intended for high speed compared to size.
- categoryBits: part of the collision filtering setup, [1]
- conveyorBeltSpeed: specific to wck, if not 0, your body should act like a conveyor belt pushing on things that contact it.
- density: how heavy your object is per unit of size. will effect how much force is needed to cause movement.
- disabled: ? unknown, sounds similar to active.
- fixedRotation: if true this object will not rotate from collisions or other forces.
- focusOn: ? unknown, perhaps involved in the screen following feature. like keeping a hero on screen in a platform game.
- friction: the amount of drag on the surfaces of this object
- groupIndex: part of the collision filtering setup, [2]
- inertiaScale: i believe this is like density, but for rotational forces specifically. higher values should require more torque to turn the object, as if more of its weight is farther from the center of rotation.
- isGround: ?unknown, perhaps involved in telling a platform hero when he can jump
- isSesnor: if true, dynamic bodies will pass right through this body, but can still dispatch a begin and end contact event. good for goals or fire etc..
- linearDamping: slows movement, generally 0.0 to 1.0, but higher numbers are applicable.
- linearVelocityX: starting x speed
- linearVelocityY: starting y speed
- maskBits: part of the collision filtering setup, [3]
- reportBeginContat: if true code can be set to receive this collision based event. fires when a contact begins, just started touching.
- reportEndContact: if true code can be set to receive this collision based event. fires when a contact ends, not touching any more.
- reportPostSolve: if true code can be set to receive this collision based event. this can be used to observe the results of a collisions forces, not applicable for sensors
- reportPreSolve: if true code can be set to receive this collision based event. this is used for oneway platforms, it can receive data just before a collision causes forces and choose to ignore the collision. not applicable for sensors
- restitution: bounciness.
- tweened: use for kenomatic type bodies, if you want its position/velocities updated by a flash IDE classic tween.
- type: 3 types...
- Dynamic: moves based on physics.
- Kenomatic: moves based on code or animation tween, does not receive collision forces
- Static: does not move
