FLAG 3.0 GET

Body

Bodies are the primary objects that can be effected by Box2D physics simulations. Each Body can be assigned a Sprite and every Actor can have multiple Bodies. Those Bodies can be attached together using Joints. Bodies are created using POLE and then manipulated using FLAG and WIND.

Class

FLAGBODY

Called by FLAG.Actor("myActor").Body("theBody")

FLAG.Actor( instanceName:String ).Body( name:String ); Parameters instanceName:String --- The name of the Actor instance in the Scene name:String --- The name of the Body created in POLE Example
FLAG.Actor("myActor").Body("theBody");
Extend Class Example
FLAGBODY.prototype.myFunction = function(){
console.log("I added to the FLAGBODY Class");
};

Properties

fb2Body:b2Body --- A FLAG enhanced Box2D Body name:String --- Name of the Body Sprite:Sprite --- The Sprite of the Body tileNext:Object --- Once a TilePath has been assigned, this is the next tile on the path
row:Number --- Row of tile col:Number --- Column of tile
tileOn:Object --- The tile the Body is on
row:Number --- Row of tile col:Number --- Column of tile

Methods

Add Decal

Adds a Sprite to the decals list of the Actor's Body Sprite.

FLAG.Actor("myActor").Body("theBody").addDecal( parameters:Object ); Parameters parameters:Object --- An object with parameters
decal:String --- Name of Sprite created in POLE Optional Parameters decalName:String --- Instance name for Sprite x:Number --- Horizontal location relative to the Body y:Number --- Vertical location relative to the Body playing:Boolean --- Toggle cycling of Sprite frames alpha:Number --- Alpha of Sprite front:Boolean --- Toggle if Sprite is rendered in front of Body's Sprite
Example
FLAG.Actor("myActor").Body("theBody").addDecal({decal:"TheDecal",decalName:"myDecal"});

Apply Force

Uses Box2D to apply gradual force to the Actor's Body.

FLAG.Actor("myActor").Body("theBody").applyForce( parameters:Object ); Parameters parameters:Object --- An object with parameters
Optional Parameters x:Number --- Amount of Horizontal force y:Number --- Amount of Vertical force atX:Number --- Horizontal vector of force atY:Number --- Vertical vector of force
Example
FLAG.Actor("myActor").Body("theBody").applyForce({x:5});

Apply Impulse

Uses Box2D to apply immediate force to the Actor's Body.

FLAG.Actor("myActor").Body("theBody").applyImpulse( parameters:Object ); Parameters parameters:Object --- An object with parameters
Optional Parameters x:Number --- Amount of Horizontal impulse y:Number --- Amount of Vertical impulse atX:Number --- Horizontal vector of force atY:Number --- Vertical vector of force
Example
FLAG.Actor("myActor").Body("theBody").applyImpulse({y:-5});

Apply Torque

Uses Box2D to apply rotational torque to the Actor's Body.

FLAG.Actor("myActor").Body("theBody").applyTorque( torque:Number ); Parameters torque:Number --- Amount of torque Example
FLAG.Actor("myActor").Body("theBody").applyTorque(3);

Camera Follow

Keeps the Actor's Body in the center of the screen.

FLAG.Actor("myActor").Body("theBody").cameraFollow(); Example
FLAG.Actor("myActor").Body("theBody").cameraFollow();

Clicked

Returns true if the Pointer is over the Actor's Body Sprite when clicked.

FLAG.Actor("myActor").Body("theBody").clicked( ); Example
FLAG.Scene.mouseDown(e){
console.log(FLAG.Actor("myActor").Body("theBody").clicked());
};

Clicked Decal

Returns true if the Pointer is over the Sprite in the Actor's Body Sprite decals list.

FLAG.Actor("myActor").Body("theBody").clicked( decal:String ); Parameters decal:String --- Instance name of Sprite in decals list Example
FLAG.Scene.mouseDown(e){
console.log(FLAG.Actor("myActor").Body("theBody").clickedDecal("myDecal"));
};

Decal

Returns a Sprite from the Actor's Body Sprite decals list.

FLAG.Actor("myActor").Body("theBody").Decal( instanceName:String ); Parameters instanceName:String --- Instance name of Sprite in decals list Example
FLAG.Actor("myActor").Body("theBody").Decal("myDecal");

Destroy

Removes and Actor's Body from the Scene.

FLAG.Actor("myActor").Body("theBody").destroy( );

Drag

Keeps the Actor's Body under the Pointer.

FLAG.Actor("myActor").Body("theBody").drag( ); Example
FLAG.Scene.mouseMove(e){
FLAG.Actor("myActor").Body("theBody").drag();
};

Get Angle

Uses Box2D to return, in degrees, the angle of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getAngle( );

Get Angular Velocity

Uses Box2D to return the angular velocity of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getAngularVelocity( );

Get Animation

Returns an object containing animation information for the Sprite of the Body.

FLAG.Actor("myActor").Body("theBody").getAnimation( ); Example
console.log(FLAG.Actor("myActor").Body("theBody").getAnimation().name);

Get Inertia

Uses Box2D to return the inertia of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getInertia( );

Get Linear Velocity

Uses Box2D to return the linear velocity of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getLinearVelocity( );

Get Mass

Uses Box2D to return the mass of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getMass( );

Get Position

Uses Box2D to return the pixel position of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").getPosition( );

Isometric Move

Moves the Actor's Body, using the arrow keys, along the isometric axis.

FLAG.Actor("myActor").Body("theBody").isometricMove( speed:Number ); Parameters speed:Number --- The speed of travel Example
FLAG.Scene.update(){
FLAG.Actor("myActor").Body("theBody").isometricMove(5);
};

Linear Move

Moves the Actor's Body, using the arrow keys, along the linear axis.

FLAG.Actor("myActor").Body("theBody").linearMove( speed:Number ); Parameters speed:Number --- The speed of travel Example
FLAG.Scene.update(){
FLAG.Actor("myActor").Body("theBody").linearMove(5);
};

Play

Sets the Actor Body Sprite to play.

FLAG.Actor("myActor").Body("theBody").play( );

Remove Decal

Removes a Sprite from the decals list of the Actor's Body Sprite.

FLAG.Actor("myActor").Body("theBody").removeDecal( decal:String ); Parameters decal:String --- Instance name of a Sprite in a decals list Example
FLAG.Scene.mouseDown(e){
FLAG.Actor("myActor").Body("theBody").removeDecal("myDecal");
};

Set Angle

Uses Box2D to set the angle of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").setAngle( angle:Number ); Parameters angle:Number --- Angle, in degrees Example
FLAG.Actor("myActor").Body("theBody").setAngle(90);

Set Animation

Sets the animation of the Actor's Body Sprite.

FLAG.Actor("myActor").Body("theBody").setAnimation( animation:String || Number ); Parameters animation:String || Number --- Name or index of animation for Sprite Example
FLAG.Actor("myActor").Body("theBody").setAnimation("Walk");

Set Awake

Uses Box2D to control the Actor's Body awake state.

FLAG.Actor("myActor").Body("theBody").setAwake( awake:Boolean ); Parameters awake:Boolean --- True is awake, false is not Example
FLAG.Actor("myActor").Body("theBody").setAwake(true);

Set Frame

Sets the frame of the Actor's Body Sprite.

FLAG.Actor("myActor").Body("theBody").setFrame( frame:String || Number ); Parameters frame:String || Number --- "startFrame" or "endFrame" or number of frame for Sprite Example
FLAG.Actor("myActor").Body("theBody").setFrame(0);

Set Linear Velocity

Uses Box2D to set the linear velocity of the Actor Body.

FLAG.Actor("myActor").Body("theBody").setLinearVelocity( parameters:Object ); Parameters parameters:Object --- Velocity parameters
x:Number --- Horizontal velocity y:Number --- Vertical velocity
Example
FLAG.Actor("myActor").Body("theBody").setLinearVelocity({x:10,y:0});

Set Position

Sets the pixel position of the Actor's Body.

FLAG.Actor("myActor").Body("theBody").setPosition( parameters:Object ); Parameters parameters:Object --- Position parameters
x:Number --- Horizontal position y:Number --- Vertical position
Example
FLAG.Actor("myActor").Body("theBody").setPosition({x:10,y:0});

Stop

Sets the Actor's Body Sprites to stop.

FLAG.Actor("myActor").Body("theBody").stop( );

Tile Path

Calculates a tile path using walkable tiles and an A-Star algorithm to move the Actor's Body to a target tile.

FLAG.Actor("myActor").Body("theBody").tilePath( parameters:Object ); Parameters parameters:Object --- Tile Path parameters
row:Number --- Row of target tile col:Number --- Column of target tile timeStep:Number --- Speed of the move diagonals:Boolean --- True if using diagonals, default is false
Example
FLAG.Scene.mouseDown(e){
FLAG.Actor("myActor").Body("theBody").tilePath({row:0,col:0,timeStep:3});
};

To Tile

Sets the pixel position of the Actor's Body to a tile.

FLAG.Actor("myActor").Body("theBody").toTile( parameters:Object ); Parameters parameters:Object --- Tile parameters
row:Number --- Row of target tile col:Number --- Column of target tile
Example
FLAG.Actor("myActor").Body("theBody").toTile({row:0,col:0});

Travel Tile Path

Called by FLAG.update. Uses the Tile Path to move the Actor's Body along the path.

FLAG.Actor("myActor").Body("theBody").travelTilePath( );

Tween Alpha

Uses FLAG.Tween to change the alpha, over time, of the Actor's Body Sprite.

FLAG.Actor("myActor").Body("theBody").tweenAlpha( parameters:Object ); Parameters parameters:Object --- Tween Alpha parameters
alpha:Number --- Target alpha duration:Number --- Number of seconds for change ease:Function --- Which easing method onComplete:Function --- Function to run when Tween is complete
Example
FLAG.Actor("myActor").Body("theBody").tweenAlpha({alpha:.25,duration:3});
POLE WIND