Keyframe Animation Model – API Reference

By |

Keyframe Animation Model

Keyframe Animaion Models are used with Sub Scenes to control FBX assets. Check the manual page for more information.

Function Description
duration()

Returns the duration of the Keyframe Animation Model.

name()

Returns the name of the Keyframe Animation Model.


duration()

Returns the duration of the Keyframe Animation Model.

Returns

number the duration of the animation

↑ Back to top


name()

Returns the name of the Keyframe Animation Model.

Returns

string the name of the animation

↑ 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?

Sub Scene – API Reference

By |

Sub Scene

A Sub Scene is used to control an imported FBX asset. Check the Manual page for more information.

Function Description
animationSpeed(anim)

This method takes a Keyframe Animation Model object and returns the animation’s speed. It will return 0 if the animation isn’t currently active.

animationTimeElapsed(anim)

This method takes a Keyframe Animation Model object and returns the time elapsed as an active animation. The time elapsed is a value from 0-1, 1 being the completion of the animation. This method will return -1 if the animation isn’t currently active.

animationTransitionTime(anim)

Returns the transition time of the animation. This is the time during which this animation and the next one will be blended in transition.

animations()

Returns an array of the currently active Keyframe Animation Models.

attachEntity(joint, entity)

This method is used to attach an Entity to a joint of your Sub Scene. For example, it can be used to attach an item to the hand of your character.

isAnimationPlaying(anim)

Returns true if the given animation is playing, false if not.

jointRotation(name)

Returns the rotation of the given joint in degrees. Joints are named within the 3D modeling software used to create the fbx file.

jointRotationQuat(name)

Returns the rotation of the given joint in Quaternion. Joints are named within the 3D modeling software used to create the fbx file.

jointScale(name)

Returns the scale of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

jointTranslation(name)

Returns the translation of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

jointWeight(name)

Returns the weight of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

meshComponents()

Returns an array containing all the 3D Models associated with the Sub Scene.

playAnimation(anim)

Plays the given Keyframe Animation Model. Optionally takes a second parameter bool looped to make the animation loop.

position()

Returns the position of the Sub Scene. The Sub Scene’s position is relative to its parent Entity.

rotation()

Returns the rotation of the Sub Scene in degrees. The Sub Scene’s rotation is relative to its parent Entity.

rotationQuat()

Returns the rotation of the Sub Scene in Quaternion. The Sub Scene’s rotation is relative to its parent Entity.

scale()

Returns the scale of the Sub Scene. The Sub Scene’s scale is relative to its parent Entity.

setAnimationSpeed(anim, speed)

This method sets the animation speed for the given Keyframe Animation Model.

setAnimationTransitionTime(anim, value)

Sets the transition time of the animation. This is the time during which this animation and the next one will be blended in transition.

setColor(r, g, b, a)

Sets the RGB color of the Sub Scene. Alpha is optional.

setJointRotation(name, value)

Sets the rotation of the given joint in degrees. Joints are named within the 3D modeling software used to create the fbx file.

setJointRotationQuat(quat)

Sets the rotation of the given joint in Quaternion. Joints are named within the 3D modeling software used to create the fbx file.

setJointScale(name, value)

Sets the scale of the given joint. Joints are named within the 3D modeling software used to create the fbx file. The scale can be given in Vec3 or as setJointScale(name, x, y, z).

setJointTranslation(name, value)

Sets the translation of the given joint. Joints are named within the 3D modeling software used to create the fbx file. The translation can be given in Vec3 or as setJointTranslation(name, x, y, z).

setJointWeight(name, value)

Sets the weight of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

setPosition(value)

Sets the position of the Sub Scene. The Sub Scene’s position is relative to its parent Entity. The position can be given as Vec3 or as setPosition(x, y, z).

setRotation(value)

Sets the rotation of the Sub Scene in degrees. The Sub Scene’s rotation is relative to its parent Entity. The rotation can be given as Vec3 or as setRotation(x, y, z).

setRotationQuat(quat)

Sets the rotation of the Sub Scene in Quaternion. The Sub Scene’s rotation is relative to its parent Entity.

setScale(value)

Sets the scale of the Sub Scene. The Sub Scene’s scale is relative to its parent Entity. The scale can be given as Vec3 or as setScale(x, y, z).

stopAnimation(anim)

Stops the given Keyframe Animation Model.


animationSpeed(anim)

This method takes a Keyframe Animation Model object and returns the animation’s speed. It will return 0 if the animation isn’t currently active.

Parameters

Keyframe Animation Model – the animation

Returns

number the speed of the animation

↑ Back to top


animationTimeElapsed(anim)

This method takes a Keyframe Animation Model object and returns the time elapsed as an active animation. The time elapsed is a value from 0-1, 1 being the completion of the animation. This method will return -1 if the animation isn’t currently active.

Parameters

Keyframe Animation Model – the animation

Returns

number the time elapsed of the animation

↑ Back to top


animationTransitionTime(anim)

Returns the transition time of the animation. This is the time during which this animation and the next one will be blended in transition.

Parameters

Keyframe Animation Model – the animation

Returns

number the transition time

↑ Back to top


animations()

Returns an array of the currently active Keyframe Animation Models.

Returns

Array the array of currently active Keyframe Animation Models.

↑ Back to top


attachEntity(joint, entity)

This method is used to attach an Entity to a joint of your Sub Scene. For example, it can be used to attach an item to the hand of your character.

Parameters

string joint – the joint name
Entity entity – the entity

↑ Back to top


isAnimationPlaying(anim)

Returns true if the given animation is playing, false if not.

Parameters

Keyframe Animation Model anim – the animation to check

Returns

boolean true if the animation is playing, false if not

↑ Back to top


jointRotation(name)

Returns the rotation of the given joint in degrees. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint

Returns

Vec3 the rotation of the joint in degrees

↑ Back to top


jointRotationQuat(name)

Returns the rotation of the given joint in degrees. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint

Returns

Quaternion the rotation of the joint in Quaternion

↑ Back to top


jointScale(name)

Returns the scale of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint

Returns

Vec3 the {x, y, z} scale of the joint

↑ Back to top


jointTranslation(name)

Returns the translation of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint

Returns

Vec3 the translation of the joint

↑ Back to top


jointWeight(name)

Returns the weight of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint

Returns

number the weight of the joint

↑ Back to top


meshComponents()

Returns an array containing all the 3D Models associated with the Sub Scene.

Returns

Array – an array of 3D Models

Returns

number the weight of the joint

↑ Back to top


playAnimation(anim)

Plays the given Keyframe Animation Model. Optionally takes a second parameter bool looped to make the animation loop.

Parameters

Keyframe Animation Model anim – the animation
bool looped – (optional) true if the animation should loop, false if not

↑ Back to top


position()

Returns the position of the Sub Scene. The Sub Scene’s position is relative to its parent Entity.

Returns

Vec3 the {x, y, z} position of the Sub Scene

↑ Back to top


rotation()

Returns the rotation of the Sub Scene in degrees. The Sub Scene’s rotation is relative to its parent Entity.

Returns

Vec3 the {x, y, z} rotation of the Sub Scene

↑ Back to top


rotationQuat()

Returns the rotation of the Sub Scene in Quaternion. The Sub Scene’s rotation is relative to its parent Entity.

Returns

Quaternion the rotation of the Sub Scene in Quaternion

↑ Back to top


scale()

Returns the scale of the Sub Scene. The Sub Scene’s scale is relative to its parent Entity.

Returns

Vec3 the {x, y, z} scale of the Sub Scene

↑ Back to top


setAnimationSpeed(anim, speed)

This method sets the animation speed for the given Keyframe Animation Model.

Parameters

Keyframe Animation Model anim – the animation
number speed – the speed

↑ Back to top


setAnimationTransitionTime(anim, value)

Sets the transition time of the animation. This is the time during which this animation and the next one will be blended in transition.

Parameters

Keyframe Animation Model anim – the animation number value the transition time

↑ Back to top


setColor(r, g, b, a)

Sets the RGB color of the Sub Scene. Alpha is optional.

Parameters

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

↑ Back to top


setJointRotation(name, value)

Sets the rotation of the given joint in degrees. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint
Vec3 value – the rotation in degrees

// example: rotate the models head to follow the players touch
let subScene;
let prev;
let delta = new Vec2(0,0);

function init(){
    subScene = this.attribute('Scene')[0]; // the sub scene is connected to this node by reference
    this.enableTouch(true);
}

function touchBegan(point){
    // save the point where the touch started
    prev = point;
}
component.touchBegan = touchBegan;

function touchMove(point){
    // calculate the distance between this touch point and the last one
    delta = new Vec2 ( delta.x + prev.x - point.x, 
                       delta.y + prev.y - point.y);
    prev = point;
}
component.touchMove = touchMove;

function update(dt){
    // change the rotation of the head joint based on the touch
    subScene.setJointRotation('head', new Vec3(-delta.x,0,-delta.y));
}

↑ Back to top


setJointRotationQuat(quat)

Sets the rotation of the given joint in Quaternion. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint
Quaternion value – the rotation in Quaternion

↑ Back to top


setJointScale(name, value)

Sets the scale of the given joint. Joints are named within the 3D modeling software used to create the fbx file. The scale can be given in Vec3 or as setJointScale(name, x, y, z).

Parameters

string name – the name of the joint
Vec3 value – the {x, y, z} scale of the joint

↑ Back to top


setJointTranslation(name, value)

Sets the translation of the given joint. Joints are named within the 3D modeling software used to create the fbx file. The translation can be given in Vec3 or as setJointTranslation(name, x, y, z).

Parameters

string name – the name of the joint
Vec3 value – the {x, y, z} translation of the joint

↑ Back to top


setJointWeight(name, value)

Sets the weight of the given joint. Joints are named within the 3D modeling software used to create the fbx file.

Parameters

string name – the name of the joint
number value – the weight of the joint

↑ Back to top


setPosition(value)

Sets the position of the Sub Scene. The Sub Scene’s position is relative to its parent Entity. The position can be given as Vec3 or as setPosition(x, y, z).

Parameters

Vec3 value – the position of the Sub Scene

↑ Back to top


setRotation(value)

Sets the rotation of the Sub Scene in degrees. The Sub Scene’s rotation is relative to its parent Entity. The rotation can be given as Vec3 or as setRotation(x, y, z).

Parameters

Vec3 value – the rotation of the Sub Scene

↑ Back to top


setRotationQuat(quat)

Sets the rotation of the Sub Scene in Quaternion. The Sub Scene’s rotation is relative to its parent Entity.

Parameters

Quaternion quat – the rotation of the Sub Scene

↑ Back to top


setScale(value)

Sets the scale of the Sub Scene. The Sub Scene’s scale is relative to its parent Entity. The scale can be given as Vec3 or as setScale(x, y, z).

Parameters

Vec3 value – the {x, y, z} scale of the Sub Scene

↑ Back to top


stopAnimation(anim)

Stops the given Keyframe Animation Model.

Parameters

Keyframe Animation Model anim – the animation to stop

↑ 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?

Pin Light – API Reference

By |

Pin Light

The Pin Light is a way to add additional light sources to your game.

Function Description
color()

Returns the color of the Light in RGB (Red, Green, Blue) format.

intensity()

Returns the intensity of the Light.

isRemoved() Returns true if the Light is removed, false if not.
isVisible()

Returns true if the light is visible, false if not.

position()

Returns the Light’s position coordinates relative to its parent.

range()

Returns the range of the Light.

remove()

Remove the light from the Scene.

rotation()

Returns the rotation of the Light in degrees.

rotationQuat()

Returns the rotation of the Light in quaternion.

setColor(color)

Sets the color of the Light.

setIntensity(value)

Sets the intensity of the Light.

setPosition(x, y, z)

Sets the new position relative to the Light’s parent. If the Light has no parent, this sets the world position of the Light.

setRange(value)

Sets the range of the Light.

setRotation(x, y, z)

Sets the rotation value of the Light, in degrees.

setRotationQuat(value)

Sets rotation value in Quaternion.

setVisible(value)

Sets the visibility of the Light; true if the Light is visible, false if not.

setWorldPosition()

Sets the Light’s position coordinates in the world (absolute position).

worldPosition()

Returns the Light’s position coordinates in the world (absolute position).


color()

Returns the Light’s color in RGB (Red, Green, Blue) format. The minimum value is 0 and the maximum is 1 (think of it as the 0-255 scale divided by 255). For example, {r:0, g:0, b:0} is black and {r:1, g:1, b:1} is white.

Returns

Vec3 {x, y, z} color pigment of the Light.

let light = this.scene().findFirst("Pin Light");
log(light.color().x); // result: the red component of the light's color.

↑ Back to top


intensity()

Returns the intensity of the Light.

Returns

number The intensity of the Light. Range is 0-1000.

↑ Back to top


isRemoved()

Returns if the Light is removed.

Returns

boolean true if the Light is removed, false if the Light is not.

↑ Back to top


isVisible()

Returns if the Light is visible.

Returns

boolean true if the Light is visible, false if the Light is not.

↑ Back to top


position()

Returns the Light’s position relative to its parent. If the Light has no parent, the result of this function will be no different than worldPosition.

Returns

Vec3 {x, y, z} relative coordinates of the Light.

↑ Back to top


range()

Returns the range of the Light. The range is how far the light reaches.

Returns

Number The range of the Light.

↑ Back to top


remove()

Remove the Light from the Scene.

↑ Back to top


rotation()

Returns the rotation of the Light in degrees.

Returns

Vec3 The {x, y, z} rotation value of the Light, in degrees.

↑ Back to top


rotationQuat()

Returns the rotation of the Light in Quaternion.

Returns

Quaternion The rotation value in Quaternion.

↑ Back to top


setColor(color)

Sets the color of the Light. Expected range of {r, g, b} is 0-1.

Parameters

Vec3 color – the {r, g, b} color

↑ Back to top


setIntensity(value)

Sets the intensity of the Light.

Parameters

Number value – the intensity of the Light, ranging from 0-1000.

↑ Back to top


setPosition(x, y, z)

Sets the new position relative to the Light’s parent. If the Light has no parent, this sets the world position of the Light.

Parameters

number x – X coordinate in 3D space
number y – Y coordinate in 3D space
number z – Z coordinate in 3D space

↑ Back to top


setRange(value)

Sets the range of the Light.

Parameters

Number value – the range of the Light

↑ Back to top


setRotation(x, y, z)

Sets the rotation value of the Light, in degrees.

Parameters

number x – the X rotation of the Light
number y – the Y rotation of the Light
number z – the Z rotation of the Light

↑ Back to top


setRotationQuat(value)

Sets rotation value in Quaternion.

Parameters

Quaternion value – The Quaternion rotation value to be set

↑ Back to top


setVisible(value)

Sets the visibility of the Light; true if the Light is visible, false if not.

Parameters

boolean value – the visibility of the Light.

↑ Back to top


setWorldPosition(value)

Sets the Light’s position coordinates in the world (absolute position).

Parameters

Vec3 value – the {x, y, z} absolute position of the Light.

↑ Back to top


worldPosition()

Returns the Light’s position coordinates in the world (absolute position).

Returns

Vec3 the {x, y, z} world coordinates of the Light

let pos = this.scene().find("Pin Light")[0].worldPosition();
log('X World Position = ' + pos.x);

↑ 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?

System – API Reference

By |

System

System functions are used to retrieve or update data on the device that your game is running on.

Static Function Description
device()

Returns the name of the device that the game is running on.

fps()

Returns the Frames Per Second that the game is running currently.

frameSize()

Returns the size of the game window on the device.

isMuteBackgroundSound()

Returns true if the background sound is muted on this device, false if not.

isMuteEffectsSound()

Returns true if effects are muted on this device, false if not.

save()

Saves all that game data custom for the specific game. This also includes the Settings object.

screenSize()

(Deprecated) Returns the designer size of the device. This refers to the frame in the UI editor, and the frame when you enter the game camera mode.

sendHapticFeedback(intensity)

Triggers haptic feedback (device vibration).

setMuteBackgroundSound(value)

Mutes or unmutes the background sound.

setMuteEffectsSound(value)

Mutes or unmutes effects.


device()

Returns the name of the device that the game is running on.

Returns

string the identification name of the device that the game is running on. Will return “preview” in the preview window.

↑ Back to top


fps()

Returns the Frames Per Second that the game is currently running at.

Returns

number the current game FPS

↑ Back to top


frameSize()

Returns the size of the game window on the device.

Returns

Vec2 the size of the game window

let width = System.frameSize().x;
let height = System.frameSize().y;

↑ Back to top


isMuteBackgroundSound()

Returns true if the background sound is muted on this device, false if not.

Returns

boolean true if background sound is muted, false if not.

↑ Back to top


isMuteEffectsSound()

Returns true if effects are muted on this device, false if not.

Returns

boolean true if effects are muted, false if not.

↑ Back to top


save()

Saves all that game data custom for the specific game. This also includes the Settings object.

↑ Back to top


screenSize()

(Deprecated) Returns the designer size of the device. This refers to the frame in the UI editor, and the frame when you enter the game camera mode. It returns a constant value: 1136×64for landscape and640×113 for portrait.

Returns

Vec2 The designer size of the device

↑ Back to top


sendHapticFeedback(intensity)

Triggers haptic feedback (device vibration). The intensity variable will adjust the strength of the vibration on iPhone, but Android doesn’t have a concept of vibration strength, so a higher intensity variable will make the vibration last slightly longer.

Parameters

number intensity – the intensity of the haptic feedback. Accepted values: 1, 2

↑ Back to top


setMuteBackgroundSound(value)

Mutes or unmutes the background sound.

Parameters

boolean value – true to mute background sound, false to unmute

↑ Back to top


setMuteEffectsSound(value)

Mutes or unmutes effects.

Parameters

boolean value – true to mute effects, false to unmute

↑ 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?

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?

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?

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?

Physics World – API Reference

By |

Physics World

These methods adjust the physics settings from the world menu. For more information, see the world options manual.

Function Description
checkSphereCollision(position, radius, filter)

Checks if anything collides with the sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

disableDeactivation(value)

When a dynamic body is not moved for a few seconds, it will go into sleep mode. In sleep mode, the physics engine skips the body’s simulation. Sleep mode can be disabled with this method. By default, sleep mode is be enabled.

getSphereCollisions(position, radius, filter)

Returns colliders with a sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

rayTest(from, to, filter)

Returns physics bodies that collide with a ray between the two given Vec3 coordinates. The object returned has the properties bodies and sensors.

Optional filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

setSubSteps(value)

Sets the value of the sub steps setting in the world options menu.

setTimeWarp(value)

Sets the value of the time warp setting in the world options menu.

subSteps()

Returns the value of sub steps from the world options menu.

timeWarp()

Returns the value of time warp from the world options menu.


checkSphereCollision(position, radius, filter)

Checks if anything collides with the sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, entity.

Parameters

Vec3 position – the position of the sphere
number radius – the radius of the sphere
string filter – / AssetModel / Entity / optional: “kAll” the filter of items to look for

Returns

boolean true if there is a collision, false if not

↑ Back to top


disableDeactivation(value)

When a dynamic body is not moved for a few seconds, it will go into sleep mode. In sleep mode, the physics engine skips the body’s simulation. Sleep mode can be disabled with this method. By default, sleep mode is be enabled.

Parameters

boolean value – true to disable deactivation, false to enable it

↑ Back to top


getSphereCollisions(position, radius, filter)

Returns colliders with a sphere at the given position with the given radius. One use case for this method would be interating through all the colliders within a sphere and adding damage to them for an explosion. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, “kGround”, value from Asset Attribute, entity.

Parameters

Vec3 position – the position of the sphere
number radius – the radius of the sphere
string filter – / AssetModel filter / Entity filter the filter of items to look for

Returns

Object with properties {bodies, sensors} – an array of bodies and an array of sensors within the sphere

↑ Back to top


rayTest(from, to, filter)

Returns physics bodies that collide with a ray between the two given Vec3 coordinates. Optionally takes a filter parameter which has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, entity.

The object returned by this function has the properties {bodies, sensors} which are each arrays. The bodies and sensors objects have the properties {object, hitPoint}.

Parameters

Vec3 from – the starting coordinate
Vec3 to – the ending coordinate
string filter – / AssetModel filter / Entity filter the filter of items to look for

Returns

Object with properties {bodies, sensors}.

// choose an object as the Selected Character with ray testing. pt is where the user tapped.

let ray = cam.screenRay(pt);
let rtst = this.scene().physicsWorld().rayTest(
        ray.origin,
        ray.origin.add(ray.direction.scale(100))
    );
    
    for (let i = 0; i < rtst.bodies.length; ++i) {
        let hit = rtst.bodies[i];
        Settings.selectedCharacter = hit.object.parentEntity().name();
        return;
    }
    

↑ Back to top


setSubSteps(value)

Sets the value of the sub steps setting in the world options menu.

Parameters

number value – the new sub steps value

↑ Back to top


setTimeWarp(value)

Sets the value of the time warp setting in the world options menu.

Parameters

number value – the new time warp value

↑ Back to top


subSteps()

Returns the value of sub steps from the world options menu.

Returns

number the sub step value

↑ Back to top


timeWarp()

Returns the value of time warp from the world options menu.

Returns

number the time warp value

↑ 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?