Actors > Properties


Alive / Dead

Kill Actor

kill actor

Immediately kills the specified actor.

If killing the current actor from its own actor behavior, the remaining logic will continue to run. We recommending using the stop block to prevent errors from happening in this case.

recycleActor([ACTOR]);

Kill Actor (after leaving screen)

kill actor after leaving screen

Instructs the game to kill the actor if it exits the screen. This is useful for "bullets" and other temporary actors that aren't of much use to hold around once they're off the screen.

[ACTOR].killSelfAfterLeavingScreen();

Is Actor alive?

actor is alive

Returns true if the specified actor is alive. Useful for checking prior to performing operations with that actor -- working with a dead actor may cause the game to crash.

[ACTOR].isAlive()

Size

Get Width / Height

width of actor

Returns the width or height of the actor.

([ACTOR].getWidth())
([ACTOR].getHeight())
([ACTOR].getWidth()/2)
([ACTOR].getHeight()/2)

Groups / Types

Get Actor Type

type of actor

Returns the actor's Actor Type.

[ACTOR].getType()

Get Group

group of actor

Returns the actor's (Collision) Group.

[ACTOR].getGroup()

Choose Actor Type

actor type

Returns the chosen Actor Type.

[ACTOR TYPE]

Choose Actor Group

actor group

Returns the chosen Actor Group. Useful for making comparisons in collision events.

getActorGroup([INT])

Get Actor Type (from name)

actor type with name text

Retrieves an Actor Type by name and returns it if it exists.

getActorTypeByName([TEXT])

Set Collision Response

set collision response of actorgroup and actorgroup to a sensor

Override the default collision response between two groups.

Collision.addResponse([ACTORGROUP], [ACTORGROUP], "sensor");
Collision.addResponse([ACTORGROUP], [ACTORGROUP], "solid");

Performance

Make Actor Always / Sometimes Active

make actor active always

Normally, actors stop updating after they're off-screen. This block can turn that option off and makes them always active no matter where they are. Choosing "sometimes" sets the actor to the default behavior.

[ACTOR].makeAlwaysSimulate();
[ACTOR].makeSometimesSimulate();

Toggle Continuous Collision Detection

enable continuous collision detection for actor

Toggles whether an actor travels through terrain at high speeds.

makeActorNotPassThroughTerrain([ACTOR]);
makeActorPassThroughTerrain([ACTOR]);

Collision Shapes

Add Rectangle Collision Shape

add rectangular collision shape x number y number w number h number to actor

Adds a new box collision shape to the actor's current animation.

[ACTOR].addRectangularShape([NUMBER], [NUMBER], [NUMBER], [NUMBER]);

Add Circle Collision Shape

add circular collision shape x number y number r number to actor

Adds a new circle collision shape to the actor's current animation.

[ACTOR].addCircularShape([NUMBER], [NUMBER], [NUMBER]);

Add Polygon Collision Shape

add polygonal collision shape to actor with vertices...

Adds a new polygon collision shape to the actor's current animation. Specify the points using the next vertex block right below.

var polygonActor:Actor = [ACTOR];
var vertices:Array<B2Vec2> = new Array<B2Vec2>();
[ACTIONS]
polygonActor.addPolygonalShape(vertices);

Add Point to Polygon Shape

vertex x number y number

Adds a point to the newly created polygon collision shape. Must be used in the add polygonal collision shape block above.

polygonActor.addVertex(vertices, [NUMBER], [NUMBER]);

For Each Collision Shape...

for each of actor

Lets you perform certain actions on each collision shape for the actor. Use the make the shape solid / a sensor, remove the shape and scale the shape blocks below.

var shapeActor:Actor = [ACTOR];
if (shapeActor.physicsMode == 0) {
  var fixture:B2Fixture = shapeActor.getBody().getFixtureList();
  while (fixture != null) {
    [ACTIONS]
    fixture = fixture.getNext();
  }
}

Make Collision Shape Solid / Sensor

make collision shape a sensor

Sets the collision shape to be solid or a sensor (not solid but still can detect collisions).

[COLLISION SHAPE].setSensor(true); //Make it a sensor
[COLLISION SHAPE].setSensor(false); //Make it solid

Remove Collision Shape

remove collision shape

Removes the collision shape from the actor.

[COLLISION SHAPE].getBody().DestroyFixture([COLLISION SHAPE]);

Resize Collision Shape

scale collision shape by number %

Resizes the collision shape in percentage terms, relative to the original size (100%).

Actor.scaleShape([COLLISION SHAPE].getShape(), [COLLISION SHAPE].getBody().getLocalCenter(), [NUMBER] / 100);

Get Collision Group for Shape

collision group of collision shape

Returns the collision group assigned to a shape. Normally the group of the actor type the shape is attached to.

engine.getGroup([COLLISION SHAPE].groupID, [COLLISION SHAPE].getUserData())

Set Collision Group for Shape

set collision group to actorgroup for collision shape

Sets the collision group for this shape.

[COLLISION SHAPE].groupID = [ACTORGROUP].ID;

Last Added Shape

last added shape

Returns the last collision shape added to the actor.

[ACTOR].getLastCreatedFixture()

Properties

Set Actor Value

set actor value text for actor to object

Associates a value with the given text key. Useful for storing (and later retrieving) arbitrary data in an actor without having to do this through other means in the toolset.

[ACTOR].setActorValue([TEXT], [VALUE]);

Get Actor Value

get actor value text for actor

Returns the value that is associated with the given text key, if available. Returns null if it doesn't exist.

[ACTOR].getActorValue([TEXT])