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.

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”, “kHinged”.
type() Returns the type of the Linker. Possible values: “kPoint”, “kFixed”, “kHinged”.
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


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”, “kHinged”.

Parameters

string value the type of the Linker
↑ Back to top


type()

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

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?

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?

Scene Path – API Reference

By |

Scene Path

The scene path is the path through the levels of your game. It is created using the start and end points on each level. To access your game’s Path object, use this.scene().path().

Function Description
anchorAtPosition(value)

Returns the anchor position and rotation at the given path position.

anchorPosition()

Returns the current anchor position of the path.

anchorRotationQuat()

Returns the current anchor rotation of the path in quaternion.

pathPosition()

Returns the current path position. The path position is simply how far along the path the game has moved.

pathSize()

Returns the path size.

pathTangent()

Returns the current path tangent.

positionOnPath(entity)

Takes an entity or 3D world position and returns the position along the game path.

setAutoPositionUpdate(value)

Enables/disables auto path update. If it is disabled, levels will not be created automatically along the game path.

setPathPosition(value)

Sets the current path position.


anchorAtPosition(value)

Returns the anchor position and rotation at the given path position.

Parameters

number value – the path position

Returns

Vec3 the {x, y, z} anchor position of the path at the given position

↑ Back to top


anchorPosition()

Returns the current anchor position of the path.

Returns

Vec3 the {x, y, z} anchor position of the path

↑ Back to top


anchorRotationQuat()

Returns the current anchor rotation of the path in quaternion.

Returns

quaternion the anchor rotation of the path

↑ Back to top


pathPosition()

Returns the current path position. The path position is simply how far along the path the game has moved.

Returns

number the current position along the path

↑ Back to top


pathSize()

Returns the path size.

Returns

Vec2 the {x, y} path size

↑ Back to top


pathTangent()

Returns the current path tangent.

Returns

Vec3 the {x, y, z} current path tangent

↑ Back to top


positionOnPath(entity)

Takes an entity or 3D world position and returns the position along the game path.

Parameters

Entity entity – the entity to find the game path position of or Vec3 pos a 3D world position

Returns

number the position on the game path of the given entity or 3D world position

↑ Back to top


setAutoPositionUpdate(value)

Enables/disables auto path update. If it is disabled, levels will not be created automatically along the game path.

Parameters

boolean value – true to enable auto position update, false to disable

↑ Back to top


setPathPosition(value)

Sets the current path position.

Parameters

number value – the new path position

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

Settings – API Reference

By |

Settings

Settings is a dummy class that can be extended in any way to store user information. Every time the user minimizes app, this class is serialized and saved in JSON format. It is restored during next game session.

// store the name of the selected character
Settings.selectedCharacter = this.entity().name();

// get the stored character name from Settings
let charName = Settings.selectedCharacter;

Variables set in the Settings class can be accessed and changed from within Xcode when you export to iOS. This can be useful for custom SDK integration, A/B testing, and more. To access the Settings class in ObjectiveC Xcode, import PTPSettingsController and use getSettingsValue and setSettingsValue. For example, setSettingsValue(“myVariable, “‘456′”) or setSettingsValue(“myVariable”, “{objectid: 123, myString:’my string here’}”).

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.

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()

Returns the screen size of the device.

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


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()

Returns the screen size of the device.

Returns

Vec2 The {x, y} size of the screen that your game is running on.

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

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