FLAG 3.0 GET

Actor

Actors are a collection of Bodies, Joints and Sprites. Every Actor must contain at least one Body. They are created using POLE and then manipulated using FLAG and WIND. Bodies of Actors are held together by Joints. Both the Bodies and Joints are available to Box2D for physics simulations.

Class

FLAGACTOR

Called by FLAG.Actor

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

Properties

bodies:Array --- List of Bodies of the Actor joints:Array --- List of Joints of the Actor layer:Number --- The layer the Actor is rendered on name:String --- The instance name of the Actor pIndex:Number --- The index of the Actor created in POLE position:Object --- The position of the Actor instance
x:Number --- Horizontal position y:Number --- Vertical position
layer:Number --- The layer the Actor is rendered on update:Function --- Optional method to run each tick of the game loop

Methods

Add Decal

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

FLAG.Actor("myActor").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").addDecal({decal:"TheDecal",decalName:"myDecal"});

Apply Force

Uses Box2D to apply gradual force to all the Actor's Bodies.

FLAG.Actor("myActor").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").applyForce({x:5});

Apply Impulse

Uses Box2D to apply immediate force to all the Actor's Bodies.

FLAG.Actor("myActor").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").applyImpulse({y:-5});

Apply Torque

Uses Box2D to apply rotational torque to all the Actor's Bodies.

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

Body

Returns a Body from the Actor's bodies list.

FLAG.Actor("myActor").Body( name:String ); Parameters name:String --- The name of a Body in the Actor's bodies list Example
FLAG.Actor("myActor").Body("Body_0");

Camera Follow

Keeps the Actor's first body in the center of the screen.

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

Clicked

Returns true if the Pointer is over any of the Actor's Bodies' Sprites when clicked.

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

Clicked Decal

Returns true if the Pointer is over any of the Sprites in the Actor Bodies' Sprite decals list.

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

Decal

Returns a Sprite from one of the Actor's Bodies' Sprite decals list.

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

Destroy

Removes and Actor and all of it's Bodies from the Scene.

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

Drag

Keeps the Actor's first Body under the Pointer and keeps the position of all other Bodies relative.

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

Get Angle

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

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

Get Angular Velocity

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

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

Get Animation

Returns an object containing animation information for the Sprite of the Actor's first Body.

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

Get Inertia

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

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

Get Linear Velocity

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

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

Get Mass

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

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

Get Position

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

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

Isometric Move

Moves all the Actor's Bodies together, using the arrow keys, along the isometric axis.

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

Joint

Returns a Joint from the Actor's joints list.

FLAG.Actor("myActor").Joint( name:String ); Parameters name:String --- Name of Joint in Actor's joints list Example
FLAG.Actor("myActor").Joint("theJoint");

Linear Move

Moves all the Actor's Bodies together, using the arrow keys, along the linear axis.

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

Play

Sets all the Actor Bodies' Sprites to play.

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

Sprite

Returns the Sprite of the Actor's first Body.

FLAG.Actor("myActor").Sprite( );

Remove Decal

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

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

Set Angle

Uses Box2D to set the angle of all the Actor's Bodies.

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

Set Animation

Sets the animation of the Actor's first Body Sprite.

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

Set Awake

Uses Box2D to control all of the Actor's Bodies to awake state.

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

Set Frame

Sets the frame of the Actor's first Body Sprite.

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

Set Linear Velocity

Uses Box2D to set the linear velocity of all Actor Bodies.

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

Set Position

Sets the pixel position of the Actor's first Body and keeps the position of all other Bodies relative.

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

Stop

Sets all the Actor Bodies' Sprites to stop.

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

Tile Path

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

FLAG.Actor("myActor").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").tilePath({row:0,col:0,timeStep:3});
};

To Tile

Sets the pixel position of the Actor's first Body to a tile and keeps the position of all other Bodies relative.

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

Tween Alpha

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

FLAG.Actor("myActor").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").tweenAlpha({alpha:.25,duration:3});
POLE WIND