Animation – API Reference

By |

Animation Node

An Animation Node creates a 2D plane that plays a PNG sequence or displays an image.

Function Description
animation() Returns the Animation object of the Animation Node. This is the actual asset of the node.
color() Returns the color of the Animation node.
depth() Returns the depth of the Animation node.
globalDepth()

Returns the depth of the Animation in a 2D World.

is3DMode() Returns true if the Animation Node is in 3D mode, and false if not.
isBillboardMode()

Returns true if the Animation is in billboard mode. An Animation in billboard mode will always face the camera.

localAABB()

Returns the local “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

position()

Returns the position of the Animation relative to its parent Entity.

rotation()

Returns the rotation of the Animation relative to its parent Entity.

scale()

Returns the scale of the Animation relative to its parent Entity.

set3DMode(value)

Set 3D Mode of the Animation node on or off.

setAnimation(value)

Sets the Animation attribute within the Animation node. This is like the “asset” of the Animation node. An Animation can be stored as a Script Attribute.

setBillboardMode(value)

Set billboard mode of the Animation node on or off. An Animation in billboard mode will always face the camera.

setColor(r, g, b, a)

Set the color of the Animation node.

setDepth(value)

Set the depth of the Animation node.

setGlobalDepth(value)

Set the depth of the Animation node in a 2D World.

setPosition(pos)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setPosition(x, y, z)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setRotation(x, y, z)

Sets the rotation of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setScale(x, y, z)

Sets the scale of the animation component relative to its parent Entity.

setVisible(value)

Sets the visibility of the 3D Model.

transformedAABB()

Returns the relative “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

transformedOBB()

Returns the “oriented bounding box” for the Animation relative to its parent Entity. OBB is more precise but more performance-heavy than AABB.

worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

worldOBB()

Returns the “oriented bounding box” for the Animation. OBB is more precise but more performance-heavy than AABB.


animation()

Returns the Animation object of the Animation Node. This is the actual asset of the node.

Returns

AnimationModel the Animation object of the Animation Node

↑ Back to top


color()

Returns the color of the Animation node. The range is 0-255 for each value (red, green, blue, alpha).

Returns

Object – the {r, g, b, a} representation of the Animation’s color.

↑ Back to top


depth()

Returns the depth of the Animation node. Depth decides which Animation is on top when the 3D Mode of the Animations is turned off. A higher value will be above a lower number.

Returns

Number – the depth of the Animation.

↑ Back to top


globalDepth()

Returns the global depth of the Animation node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Returns

number value – The global depth of the Animation

↑ Back to top


is3DMode()

Returns

boolean true if the Animation is in 3D mode, false if not

↑ Back to top


isBillboardMode()

Returns true if the Animation is in billboard mode. An Animation in billboard mode will always face the camera.

Returns

boolean true if the Animation is in billboard mode, false if not

↑ Back to top


localAABB()

Returns the local “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


position()

Returns the position of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative position coordinates of the Animation

↑ Back to top


rotation()

Returns the rotation of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative rotation of the Animation

↑ Back to top


scale()

Returns the scale of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative scale of the Animation

↑ Back to top


set3DMode(value)

Set 3D Mode of the Animation node on or off.

Parameters

boolean value – True to turn 3D mode on, false to turn it off

↑ Back to top


setAnimation(value)

Sets the Animation attribute within the Animation node. This is like the “asset” of the Animation node. An Animation can be stored as a Script Attribute.

Parameters

AnimationModel value – the AnimationModel to set the Animation attribute to.

↑ Back to top


setBillboardMode(value)

Set billboard mode of the Animation node on or off. An Animation in billboard mode will always face the camera.

Parameters

boolean value – True to turn billboard mode on, false to turn it off

↑ Back to top


setColor(r, g, b, a)

Sets the color of the Animation node. The range is 0-255 for each value (red, green, blue, alpha). Alpha is optional.

Parameters

number r – the red component of the color
number g – the green component of the color
number b – the blue component of the color
number a – the alpha component of the color (optional)

↑ Back to top


setDepth(value)

Sets the depth of the Animation node. Depth decides which Animation is on top when the 3D Mode of the Animations is turned off. A higher value will be above a lower number in the Scene.

Parameters

number value – The depth of the Animation

↑ Back to top


setGlobalDepth(value)

Sets the global depth of the Animation node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Parameters

number value – The global depth of the Animation

↑ Back to top


setPosition(pos)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

Parameters

Vec3 pos – The new {x, y, z} relative coordinates of the Animation

↑ Back to top


setPosition(x, y, z)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

Parameters

number x – The x component of the new position
number y – The y component of the new position
number z – The z component of the new position

↑ Back to top


setRotation(x, y, z)

Sets the rotation of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units. Can optionally take a Vec3 argument.

Parameters

number x – The x component of the new rotation
number y – The y component of the new rotation
number z – The z component of the new rotation

or

Vec3 – The {x, y, z} rotation

↑ Back to top


setScale(x, y, z)

Sets the scale of the animation component relative to its parent Entity.

Parameters

number x – The x component of the new scale
number y – The y component of the new scale
number z – The z component of the new scale

↑ Back to top


setVisible(value)

Sets the visibility of the 3D Model.

Parameters

boolean value – true for visible, false for not visible.

↑ Back to top


transformedAABB()

Returns the relative “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


transformedOBB()

Returns the “oriented bounding box” for the Animation relative to its parent Entity. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing relative OBB data

↑ Back to top


worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing world AABB data

↑ Back to top


worldOBB()

Returns the “oriented bounding box” for the Animation. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing OBB data

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Linker – API Reference

By |

Linker

A Linker is a feature of the Outline menu. Similar to a physics constraint, it “links” two physics-enabled entities together, connected by a joint. At least one of these entities should be Dynamic physics type for it to function. For examples on how to use a hinge type linker, check out the Motor node or the Iso Car template.

There are three types of Linkers:
Point – A point Linker is a physics constraint between two physics objects with a pivot point that describes the ‘ballsocket’ between them. This is useful for something like a light hanging from the ceiling by a string.
Fixed – A fixed Linker constrains two physics objects by keeping them the same relative distance from each other. In a way, it pins them together.
Hinge – A hinge Linker constrains physics objects along an axis by a hinge. The hinge constraint is unique because you can apply force to the hinge to rotate the axis. This can be used to simulate wheels that rotate around an axis, for example.

Note: Currently if you want to access a Linker in the start() function of a script, you’ll need to call .init() on it first.

Function Description
enableMotor(value)

Enables/disables a hinge type Linker’s angular motor.

entityA() Returns the first entity linked by the Linker. Whichever one is considered “entity A” depends on which one is higher in the scene editor at the time of creating the Linker.
entityB() Returns the second entity linked by the Linker. Whichever one is considered “entity B” depends on which one is higher in the scene editor at the time of creating the Linker.
hingeAxis() Returns the hinge axis of a hinge type Linker.
init() Initializes the Linker. This is necessary for accessing a Linker in the start() method.
isRemoved() Returns true if the Linker is removed, false if not.
maxMotorImpulse() Returns the max motor impulse of the hinge type Linker.
motorVelocity()

Returns the motor velocity of the hinge type Linker.

name() Returns the name of the Linker.
position()

Returns the position of the Linker.

remove()

Removes/disables the Linker.

setEntities(entity1, entity2)

Sets the entities that the Linker connects.

setHingeAxis(value)

Set the hinge axis of a hinge type Linker.

setMaxMotorImpulse(value)

Sets the max motor impulse of the hinge type Linker.

setMotorVelocity(value)

Sets the motor velocity of the hinge type Linker.

setPosition(value)

Sets the position of the Linker.

setType(value) Sets the Linker type. Accepted values are “kPoint”, “kFixed”, “kHinge”.
type() Returns the type of the Linker. Possible values: “kPoint”, “kFixed”, “kHinge”.
Static Function Description
entityLinkers(entity)

Returns an array of all Linkers attached to the given entity.


enableMotor(value)

Enables/disables a hinge type Linker’s angular motor.

Parameters

boolean value – true to enable, false to disable

↑ Back to top


entityA()

Returns the first entity linked by the Linker. Whichever one is considered “entity A” depends on which one is higher in the scene editor at the time of creating the Linker.

Returns

Entity the first entity linked by the Linker.

↑ Back to top


entityB()

Returns the second entity linked by the Linker. Whichever one is considered “entity B” depends on which one is higher in the scene editor at the time of creating the Linker.

Returns

Entity the second entity linked by the Linker.
↑ Back to top


hingeAxis()

Returns the hinge axis of a hinge type Linker.

Returns

Vec3 the {x, y, z} hinge axis
↑ Back to top


init()

Initializes the Linker. This is necessary for accessing a Linker in the start() method.

function start(){
  let linker = this.scene().find("Linker")[0];
  linker.init();
  // do whatever you need to with your linker now.
}

↑ Back to top


isRemoved()

Returns true if the Linker is removed, false if not.

Returns

boolean true if Linker is removed, false if not

↑ Back to top


maxMotorImpulse()

Returns the max motor impulse of the hinge type Linker.

Returns

number the max motor impulse
↑ Back to top


motorVelocity()

Returns the motor velocity of the Linker.

Returns

number the motor velocity of the Linker
↑ Back to top


name()

Returns the name of the Linker.

Returns

string the name of the Linker
↑ Back to top


position()

Returns the position of the Linker.

Returns

Vec3 the {x, y, z} position of the Linker
↑ Back to top


remove()

Removes/disables the Linker.

↑ Back to top


setEntities(entity1, entity2)

Sets the entities that the Linker connects.

Parameters

Entity entity1 – the first entity to connect to the Linker
Entity entity2 – the second entity to connect to the Linker
↑ Back to top


setHingeAxis(value)

Set the hinge axis of a hinge type Linker.

Parameters

Vec3 value the {x, y, z} hinge of the Linker
↑ Back to top


setMaxMotorImpulse(value)

Sets the max motor impulse of the hinge type Linker.

Parameters

number value the max motor impulse
↑ Back to top


setMotorVelocity()

Sets the motor velocity of the hinge type Linker.

Parameters

number value the motor velocity
↑ Back to top


setPosition(value)

Sets the position of the Linker.

Parameters

Vec3 value the {x, y, z} position of the Linker.
↑ Back to top


setType(value)

Sets the Linker type. Accepted values are “kPoint”, “kFixed”, “kHinge”.

Parameters

string value the type of the Linker
↑ Back to top


type()

Returns the Linker type. Possible values: “kPoint”, “kFixed”, “kHinge”.

Returns

string the type of the Linker
↑ Back to top


entityLinkers(entity)

Returns an array of all Linkers attached to the given entity. This is a static function, so it is called like this: Linker.entityLinkers(entity);

Parameters

Entity entity the entity

Returns

array the array of Linkers attached to the entity
↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Label Node – API Reference

By |

Label Node

Function Description
globalDepth()

Returns the depth of the Label in a 2D World.

isRemoved() Returns true if the Label is removed, false if not.
opacity()

Returns the opacity of the label.

position()

Returns the position of the label.

setGlobalDepth(value)

Set the depth of the Label node in a 2D World.

setOpacity(value)

Sets the opacity of the label.

setPosition(x, y)

Sets the position of the label.

setText(value)

Sets the text for the label.


globalDepth()

Returns the global depth of the Label node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Returns

number value – The global depth of the Label

↑ Back to top


isRemoved()

Returns true if the Label is removed, false if not.

Returns

boolean true if Label is removed, false if not

↑ Back to top


opacity()

Returns the opacity of the label. Ranges from 0 (invisible) to 255 (fully opaque)

Returns

number the opacity of the label

↑ Back to top


position()

Returns the position of the label.

Returns

Vec2 the {x, y} position of the label.

↑ Back to top


setGlobalDepth(value)

Sets the global depth of the Label node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Parameters

number value – The global depth of the Label

↑ Back to top


setOpacity(value)

Sets the opacity of the label. Ranges from 0 (invisible) to 255 (fully opaque)

Parameters

number value – The opacity of the label

↑ Back to top


setPosition(x, y)

Sets the position of the label.

Parameters

number x – the x coordinate position
number y – the y coordinate position
number z – the z coordinate position (optional)

↑ Back to top


setText(value)

Sets the text for the label.

Parameters

string value – The string that will be displayed by the label.

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Label – API Reference

By |

Label

Function Description
position()

Returns the position of the label.

setOpacity(value)

Sets the opacity of the label.

setPosition(value)

Sets the position of the label.

setText(value)

Sets the text for the label.


position()

Returns the position of the label.

Returns

Vec2 the {x, y} position of the label.

↑ Back to top


setOpacity(value)

Sets the opacity of the label. Ranges from 0 (invisible) to 255 (fully opaque)

Parameters

number value – The opacity of the label

↑ Back to top


setPosition(value)

Sets the position of the label.

Parameters

Vec2 value – the {x, y} coordinates of the position

↑ Back to top


setText(value)

Sets the text for the label.

Parameters

string value – The string that will be displayed by the label.

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Image – API Reference

By |

Image

Images are added on UI Screens.

Function Description
setOpacity(value)

Sets the opacity of the image.

setVisible(value)

Sets the visibility of the image.


setOpacity(value)

Sets the opacity of the image.

Parameters

number value – the new opacity of the Image, range 0-255

    let image = this.ui().find("myImage")[0];
    image.setOpacity(0.5);

↑ Back to top


setVisible(value)

Sets the visibility of the image.

Parameters

boolean value – true to set the Image to visible, false if not

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

enableTouch() – API Reference

By |

ENABLETOUCH(SWALLOW, PRIORITY)

Enables touch events. Component will start receiving events for three functions
If swallow (optional) is set to true, then entities with lower priority will not receive their touch events.
priority (optional) can be negative or positive. Based on priority engine will device who receive touch event first

touchBegin(point)– player touches the screen
touchMove(point) – player moves a finger
touchEnd – player lifts a finger

Add this extra code to your component in order to handle these new events:

function touchBegan( point ){
  //player touches the screen
  /*Return true or false to tell if touch should be swallowed. If touch is swallowed, then other touch events with lower priority will not be triggered*/
  return true; 
}
component.touchBegan = touchBegan;

function touchMove( point ){
  //player moves a finger
}
component.touchMove = touchMove;

function touchEnded(){
  //player lifts a finger
}
component.touchEnded = touchEnded;

emitSignal(name, value) – API Reference

By |

EMITSIGNAL(NAME, VALUE)

Sends a signal via an output connection.

name – Name of the output used to emit the signal.
value – Data sent in the signal.

function init(){
  this.emitSignal('Object', 'Obstacle');
}

Button – API Reference

By |

Button

Function Description
activate()

Triggers the action assigned to the button as if it was tapped.

isVisible()

Returns true if the Button is visible, false if not. If a Button is not visible it cannot be tapped.

onClick

Function assigned to this property will be executed when user touches the button.

opacity()

Returns the opacity of the button.

position()

Returns position of the button.

rotation()

Returns the rotation of the button.

scale()

Returns the scale of the button.

setOpacity(value)

Sets the opacity of a button. Note: Setting the opacity to 0 will make the button invisible, but still tappable. If you’d like to hide a button entirely, use setVisible(false).

setPosition(value)

Sets the screen position of the button.

setRotation(value)

Sets the 2D rotation of the button in degrees.

setScale(value)

Sets the 2D scale of the button.

setVisible(value)

Sets the visibility of a button. If a button is not visible, it cannot be tapped. If you’d like an invisible but tappable button, use setOpacity(0).


activate()

Triggers the action assigned to the button as if it was tapped.

↑ Back to top


isVisible()

Returns true if the Button is visible, false if not. If a Button is not visible it cannot be tapped.

Returns

boolean true if the Button is visible, false if not

↑ Back to top


onClick

Function assigned to this property will be executed when user touches the button.

  let button = this.ui().find('MyButton')[0];
  button.onClick = function(){
    Ads.showInterstitial();
  }

↑ Back to top


opacity()

Returns the opacity of the button.

Returns

number the opacity of the button. Range: 0-255.

↑ Back to top


position()

Returns position of the button.

Returns

Vec3 {x, y, z} position of the button.

↑ Back to top


rotation()

Returns the rotation of the button.

Returns

Vec3 {x, y, z} rotation of the button.

↑ Back to top


scale()

Returns the scale of the button.

Returns

Vec {x, y, z} scale of the button.

↑ Back to top


setOpacity(value)

Sets the opacity of a button. Note: Setting the opacity to 0 will make the button invisible, but still tappable. If you’d like to hide a button entirely, use setVisible(false).

Parameters

number value – Range: 0-255. The lower the value, the less opaque the button becomes.

↑ Back to top


setPosition(value)

Sets the screen position of the button.

Parameters

Vec2 value – the {x, y} position

↑ Back to top


setRotation(value)

Sets the 2D rotation of the button in degrees.

Parameters

number value – the new rotation in degrees

↑ Back to top


setScale(value)

Sets the 2D scale of the button.

Parameters

Vec2 value – the {x, y} new scale

↑ Back to top


setVisible(value)

Sets the visibility of a button. If a button is not visible, it cannot be tapped. If you’d like an invisible but tappable button, use setOpacity(0).

Parameters

boolean value – true for visible, false for not visible.

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Brainevents – API Reference

By |

Brainevents

Brainevents activate gameplay features and logic in a sequential order that is determined by the object or player action. See more at the Brainevents documentation page.

Function Description
addBrainEventCallback(name, function)

Adds a callback function to trigger when the Brainevent is triggered. An event can only have one callback attached to it at a time. If addBrainEventCallback() is used on an event that already has a callback, it will replace the existing one with the new one.

currentEvent()

Returns the name of the current or most recent event. If there is no such event, returns an empty string.

hasEvent(name)

Returns true if the entity has an event of the given name, or false if not.

removeBrainEventCallback(name)

Removes the callback attached to the given Brainevent. Remember, each event can only have one callback associated with it.

setEvent(name)

Triggers the event passed as a parameter, also setting it as the entity’s current event. If no data is passed, the event will pass a boolean true value.


addBrainEventCallback(name, function)

Adds a callback function to trigger when the Brainevent is triggered. An event can only have one callback attached to it at a time. If addBrainEventCallback() is used on an event that already has a callback, it will replace the existing one with the new one.

Parameters

string name – the name of the event function the callback function to execute when the event is triggered

if (this.entity().hasEvent('MyEvent')) {
    this.entity().addBrainEventCallback('MyEvent', function() {
        log('In MyEvent Callback!');
        return true;
    });
}

↑ Back to top


currentEvent()

Returns the name of the current or most recent event. If there is no such event, returns an empty string.

Returns

string – the name of the current event

↑ Back to top


hasEvent(name)

Returns true if the entity has an event of the given name, or false if not.

Parameters

string name – the name of the event

Returns

boolean – true if the entity has the event, false if not

↑ Back to top


removeBrainEventCallback(name)

Removes the callback attached to the given Brainevent. Remember, each event can only have one callback associated with it.

Parameters

string name – the name of the event

↑ Back to top


setEvent(name)

Triggers the event passed as a parameter, also setting it as the entity’s current event. If no data is passed, the event will pass a boolean true value.

Parameters

string name – the name of the event
data (optional) value passed to the event of data type boolean, number, or string

this.entity().setEvent('AttackEventName');

↑ Back to top