Function References

These expressions can be used only inside a field like this :

More info about expressions.

String Expressions


Conversion

Function Description
LargeNumberToString(num) Convert number with scientific notation to text without scientific notation
ToString(num) Convert number to text
GlobalVarToJSON(var) Convert global variable to JSON
ObjectVarToJSON(var, num) Convert object variable to JSON
ToJSON(var) Convert variable to JSON

Variables

Function Description
GlobalVariableString(var) Return the text of a global variable
VariableString(var) Return the text of a scene variable

Keyboard

Function Description
LastPressedKey() Return the last pressed key

Scene

Function Description
CurrentSceneName() Return the current scene name

Screen

Function Description
WindowTitle() Return the window’s title

Manipulation of Text

Function Description
FromCodePoint(num) Return character from the code point
NewLine() Insert a new line
StrAt(“text”, num) Get a character from a text
StrRepeat(“text”, repCount) Repetition of a text with the help of repetition count
SubStr(“text”, portionPos, 5) Return part of a string
ToLowerCase(“text”) Lowercase a text
ToUpperCase(“text”) Uppercase a text

You can learn more about manipulating text in expressions here.

Functions

Function Description
GetArgumentAsString(“parameterName”) Get function parameter text

Facebook Instant Games

Function Description
FacebookInstantGames::PlayerId() Player Identifier
FacebookInstantGames::PlayerName() Player Name

Filesystem


Windows, Linux, MacOS

Function Description
FileSystem::DesktopPath() Desktop folder
FileSystem::DocumentsPath() Documents folder
FileSystem::ExecutablePath() Game’s executable folder
FileSystem::PathDelimiter() Path delimiter
FileSystem::PicturesPath() Pictures folder
FileSystem::TempPath() Temp folder
FileSystem::UserdataPath() User data folder

Common expressions for all objects


Objects

Function Description
object.ObjectName() Return the name of the object

Variables

Function Description
object.VariableString(var) Return the variable of the object

Sprite


Animations and images

Function Description
object.AnimationName() Return the name of the animation of the selected sprite

Text object


Text

Function Description
object.String() Return the text of the object

Particle system


Particles

Function Description
object.Texture() Returns the name of the image displayed by the particle

Text entry object


Text entered with keyboard

Function Description
object.String() Return the text entered with keyboard

Numerical Expressions


Common expressions for all objects


Objects

Function Description
Count(object) Returns the instances of object

Angle

Function Description
object.Angle() Returns the angle of the object

Position

Function Description
obj1.Distance(obj2) Returns the distance between 2 objects
obj1.SqDistance(obj2) Returns the square of the distance between 2 objects
object.X() Returns the X-coordinate of the object
object.Y() Returns the Y-coordinate of the object

Movement

Function Description
object.ForceAngle() Returns the average force angle of all the forces combined
object.ForceLength() Returns the average length of all the forces combined
object.ForceX() Returns the average X-coordinates of all the forces combined
object.ForceY() Returns the average Y-coordinates of all the forces combined

Size

Function Description
object.Height() Returns the height of the object
object.Width() Returns the width of the object

Timers

Function Description
object.ObjectTimerElapsedTime(“timerName”) The time elapsed of the timer of an object

Variables

Function Description
object.Variable(var) Returns the variable of an object
object.VariableChildCount(var) Object’s variable number of children

Visibility

Function Description
object.Zorder() Returns the Z-order value of an object

Conversion

Function Description
ToDeg(angRads) Converts Radians to Degrees
ToNumber(“text”) Converts text to number
ToRad(angDegs) Converts Degrees to Radians

Variables

Function Description
GlobalVariable(globalVar) Returns the value of a global variable
GlobalVariableChildCount(globalVar) Returns the number of children of a flobal variable
Variable(sceneVar) Returns the value of a scene variable
VariableChildCount(sceneVar) Returns the number of children of a scene variable

Multitouch

Function Description
LastEndedTouchId() Returns the identifier of the last ended touch
LastTouchId() Returns the identifier of the last touch
TouchX(touchID, “layer”, camera) Returns the X-coordinate of the touch
TouchY(touchID, “layer”, camera) Returns the Y-coordinate of the touch

Mouse cursor

Function Description
MouseX(“layer”, camera) Returns the X-coordinate of the cursor
MouseY(“layer”, camera) Returns the Y-coordinate of the cursor

Random

Function Description
Random(max) Returns random integer less than max
RandomFloat(max) Returns random float less than max
RandomFloatInRange(min, max) Returns random float between min and max
RandomInRange(min, max) Returns random integer between min and max
RandomWithStep(min, max, step) Returns random number equal to (number = min + N*step < max, where N is an integer)

Time

Function Description
Time(unit) Returns current time in specified units (hours, mins, secs, etc)
TimeDelta() Returns the time elapsed since the last image
TimeFromStart() Returns the time elapsed since the beginning of the scene
TimerElapsedTime(“timerName”) Returns the value of the scene timer

Mathematical tools

Function Description Notes
angleDifference(A, B) Difference between two angles Returns the difference between the angles A and B
abs(A) Absolute value. If A is negative, returns -A otherwise returns A.
acos(A) Arc-cosine. Returns the angle, measured in radians, whose cosine is A.
acosh(A) Hyperbolic arc-cosine. Same as acos() but for hyperbolic cosine.
asin(A) Arc-sine. Returns the angle, measured in radians, whose sine is A.
atan(A) Arc-tangent. Returns the angle, measured in radians, whose tangent is (A).
atan2(A,B) Arc-tangent of A/B. The two main differences with atan() are that a) it will return the right angle depending on the signs of A and B (atan() can only return values betwen -pi/2 and pi/2), and that b) the return value of pi/2 and -pi/2 are possible.
atanh(A) Hyperbolic arc-tangent. Same as atan(), but for hyperbolic tangent.
cbrt(A) Cube root Returns the value whose cube is A.
ceil(A) Ceiling. Returns the smallest integer greater than A. Rounds up to the next higher integer.
clamp(A, B, C) Clamp Restrict the value in the given interval (A is the value, B in min, C is max).
cos(A) Cosine in radians. Returns the cosine of the angle A, where A is measured in radians.
cosh(A) Hyperbolic cosine. Same as cos(), but for hyperbolic cosine.
cot(A) Cotangent. Cotangent of A (equivalent to 1/tan(A)).
csc(A) Cosecant. Cosecant of A (equivalent to 1/sin(A)).
exp(A) Exponential. Returns the value of e raised to the power A where e is the base of the natural logarithm, i.e. the non-repeating value approximately equal to 2.71828182846.
floor(A) Floor. Returns the largest integer less than A. Rounds down to the next lower integer.
lerp(A, B, C) Linear interpolation. Return the value interpolates between two other values A and B along C.
log(A) Natural logarithm. Natural (base e) logarithm of A.
log10(A) Base 10 logarithm. Base 10 logarithm of A.
log2(A) Base 2 logarithm. Base 2 logarithm of A.
max(A,B) Maximum. If A>B, the result is A, else B.
min(A,B) Minimum. If A<B, the result is A, else B.
mod(x,y) Modulo. Return the result of x mod y.
nthroot(A, N) Nth Root. Returns the number whose nth power is A.
pow(A,B) Exponentiation A raised to the power B.
round(A) Round to integer. Rounds A to the closest integer. 0.5 is rounded to 1.
sec(A) Secant. Secant of A (equivalent to 1/cos(A)).
sign(A) Sign of a number. Returns the sign of A, i.e. whether A is positive or negative
sin(A) Sine. Returns the sine of the angle A, where A is measured in radians.
sinh(A) Hyperbolic sine. Same as sin() but for hyperbolic sine.
sqrt(A) Square root. Returns the value whose square is A.
tan(A) Tangent. Returns the tangent of the angle A, where A is measured in radians.
tanh(A) Hyperbolic tangent. Same as tan() but for hyperbolic tangent.
trunc(A) Truncate. Returns the integer part of a number by removing any fractional digits.

Layers and cameras

Function Description
CameraHeight(“layer”, camNum) Returns the height of a camera of a layer
CameraRotation(“layer”, camNum) Returns the angle of a camera of a layer
CameraWidth(“layer”, camNum) Returns the width of a camera of a layer
CameraX(“layer”, camNum) Returns the X-coordinate of a camera of a layer
CameraY(“layer”, camNum) Returns the Y-coordinate of a camera of a layer
LayerTimeScale(“layer”) Returns the time scale of a layer

Sound level

Function Description
GlobalVolume() Returns the global volume

Music

Function Description
MusicChannelPitch(channel) Returns the music pitch of a channel
MusicChannelPlayingOffset(channel) Returns the music playing offset of a channel
MusicChannelVolume(channel) Returns the music volume of a channel

Sounds

Function Description
SoundChannelPitch(channel) Returns the sound pitch of a channel
SoundChannelPlayingOffset(channel) Returns the sound playing offset of a channel
SoundChannelVolume(channel) Returns the sound volume of a channel

Screen

Function Description
SceneWindowHeight() Returns the height of the scene window
SceneWindowWidth() Returns the width of the scene window
ScreenHeight() Returns the height of the screen
ScreenWidth() Returns the width of the screen

Manipulation of Text

Function Description
StrFind(“text”, “whatToSearch”) Return the position of the word searched, if any. Else, return -1
StrFindFrom(“text”, “whatToSearch”, posNum) Find one string within another from position
StrLength(“text”) Return the length of text
StrRFind(“text”, “toSearchFromEnd”) Return the position of the word search from the end, if any. Else, return -1
StrRFindFrom(“text”, “toSearchFromEnd”, lastPosNum) Find one string within another from position from the end of the string

Learn more about manipulating text in expressions here.

Functions

Function Description
GetArgumentAsNumber(“parameterName”) Get the value of function parameter as a number

Inventory

Function Description
Inventory::Count(“inventory”, “item”) Count the instance of item in inventory

Sensors


Motion

Function Description
DeviceSensors::AccelerationX() Returns the acceleration of the device in X direction
DeviceSensors::AccelerationY() Returns the acceleration of the device in Y direction
DeviceSensors::AccelerationZ() Returns the acceleration of the device in Z direction
DeviceSensors::RotationAlpha() Returns the rotation of the device with respect to the X direction
DeviceSensors::RotationBeta() Returns the rotation of the device with respect to the Y direction
DeviceSensors::RotationGamma() Returns the rotation of the device with respect to the Z direction

Orientation

Function Description
DeviceSensors::OrientationAbsolute() Returns the absolute orientation of the device
DeviceSensors::OrientationAlpha() Returns the orientation of the device with respect to the X direction
DeviceSensors::OrientationBeta() Returns the orientation of the device with respect to the Y direction
DeviceSensors::OrientationGamma() Returns the orientation of the device with respect to the Z direction

Sprite


Animations and images

Function Description
object.Animation() Returns the animation of the object
object.AnimationSpeedScale() Returns the animation speed scale of the object
object.Sprite() Returns the sprite image of the object

Direction

Function Description
object.Direction() Returns the direction of the object

Opacity

Function Description
object.Opacity() Returns the opacity of the object

Position

Function Description
object.PointX(“point”) Returns the X-coordinate of a point in object
object.PointY(“point”) Returns the Y-coordinate of a point in object

Size

Function Description
object.ScaleX() Returns the scale of the width of the object
object.ScaleY() Returns the scale of the height of the object

Text object


Rotation

Function Description
textObject.Angle() Returns the angle of the text object

Opacity

Function Description
textObject.Opacity() Returns the opacity of the text object

Particle system


Common

  • Object.EmitterAngle()
  • Object.EmitterForceMax()
  • Object.EmitterForceMin()
  • Object.Flow()
  • Object.ParticleGravityAngle()
  • Object.ParticleGravityLength()
  • Object.Tank() - capacity
  • Object.ZoneRadius()

Advanced

  • Object.EmitterAngleA()
  • Object.EmitterAngleB()

Particles

  • Object.NbParticles() - number

Setup

  • Object.ParticleAlpha1()
  • Object.ParticleAlpha2()
  • Object.ParticleBlue1()
  • Object.ParticleBlue2()
  • Object.ParticleGravityX()
  • Object.ParticleGravityY()
  • Object.ParticleGreen1()
  • Object.ParticleGreen2()
  • Object.ParticleLifeTimeMax()
  • Object.ParticleLifeTimeMin()
  • Object.ParticleRed1()
  • Object.ParticleRed2()
  • Object.ParticleSize1()
  • Object.ParticleSize2()
  • Object.RendererParam1()
  • Object.RendererParam2()

Other functions in Particle System

  • Object.EmitterXDirection()
  • Object.EmitterYDirection()
  • Object.EmitterZDirection()
  • Object.ParticleAngle1()
  • Object.ParticleAngle2()
  • Object.ParticleGravityZ()
  • Object.Friction()

Video

Function Description
Object.CurrentTime() Return the current time of a video object (in seconds).
Object.Duration() Return the duration of a video object (in seconds).
Object.Opacity() Return the opacity of a video object
Object.PlaybackSpeed() Return the playback speed of a video object
Object.Volume() Get the volume of a video object, between 0 (muted) and 100 (maximum).

Platform Behavior


Options

  • Object.PlatformerObject::Acceleration()
  • Object.PlatformerObject::Deceleration()
  • Object.PlatformerObject::Gravity()
  • Object.PlatformerObject::JumpSpeed()
  • Object.PlatformerObject::MaxFallingSpeed()
  • Object.PlatformerObject::MaxSpeed()

Top-down movement


Movement

  • Object.TopDownMovement::Acceleration()
  • Object.TopDownMovement::Angle()
  • Object.TopDownMovement::AngleOffset()
  • Object.TopDownMovement::AngularMaxSpeed()
  • Object.TopDownMovement::Deceleration()
  • Object.TopDownMovement::MaxSpeed()
  • Object.TopDownMovement::Speed()
  • Object.TopDownMovement::XVelocity()
  • Object.TopDownMovement::YVelocity()

Pathfinding behavior


Path

  • Object.Pathfinding::Acceleration()
  • Object.Pathfinding::AngleOffset()
  • Object.Pathfinding::AngularMaxSpeed()
  • Object.Pathfinding::DestinationX()
  • Object.Pathfinding::DestinationY()
  • Object.Pathfinding::ExtraBorder()
  • Object.Pathfinding::GetNodeX(nodeIndexFrom0)
  • Object.Pathfinding::GetNodeY(nodeIndexFrom0)
  • Object.Pathfinding::LastNodeX()
  • Object.Pathfinding::LastNodeY()
  • Object.Pathfinding::MaxSpeed()
  • Object.Pathfinding::NextNodeIndex()
  • Object.Pathfinding::NextNodeX()
  • Object.Pathfinding::NextNodeY()
  • Object.Pathfinding::NodeCount()
  • Object.Pathfinding::Speed()

Virtual grid

  • Object.Pathfinding::CellHeight()
  • Object.Pathfinding::CellWidth()

Obstacles

  • Object.Pathfinding::Cost()

Physics Engine (depreciated)


Rotation

  • Object.Physics::AngularDamping()
  • Object.Physics::AngularVelocity()

Displacement

  • Object.Physics::LinearDamping()
  • Object.Physics::LinearVelocity()
  • Object.Physics::LinearVelocityX()
  • Object.Physics::LinearVelocityY()

Collision polygon

  • Object.Physics::PolygonScaleX()
  • Object.Physics::PolygonScaleY()

Physics Engine 2.0


Body settings

  • Object.Physics::AngularDamping()
  • Object.Physics::Density()
  • Object.Physics::Friction()
  • Object.Physics::GravityScale()
  • Object.Physics::LinearDamping()
  • Object.Physics::Restitution()

Velocity

  • Object.Physics::AngularVelocity()
  • Object.Physics::LinearVelocity()
  • Object.Physics::LinearVelocityX()
  • Object.Physics::LinearVelocityY()

Joints


Distance
  • Object.Physics::DistanceJointDampingRatio(jointID)
  • Object.Physics::DistanceJointFrequency(jointID)
  • Object.Physics::DistanceJointLength(jointID)
Friction
  • Object.Physics::FrictionJointMaxForce(jointID)
  • Object.Physics::FrictionJointMaxTorque(jointID)
Gear
  • Object.Physics::GearJointFirstJoint(jointID)
  • Object.Physics::GearJontRatio(jointID)
  • Object.Physics::GearJointSecondJoint(jointID)
Other Functions in Joints
  • Object.Physics::JointFirstAnchorX(jointID)
  • Object.Physics::JointFirstAnchorY(jointID)
  • Object.Physics::JointReactionForce(jointID)
  • Object.Physics::JointReactionTorque(jointID)
  • Object.Physics::JointSecondAnchorX(jointID)
  • Object.Physics::JointSecondAnchorY(jointID)
Motor
  • Object.Physics::MotorJointAngularOffset(jointID)
  • Object.Physics::MotorJointCorrectionFactor(jointID)
  • Object.Physics::MotorJointMaxForce(jointID)
  • Object.Physics::MotorJointMaxTorque(jointID)
  • Object.Physics::MotorJointOffsetX(jointID)
  • Object.Physics::MotorJointOffsetY(jointID)
Mouse
  • Object.Physics::MouseJointDampingRatio(jointID)
  • Object.Physics::MouseJointFrequency(jointID)
  • Object.Physics::MouseJointMaxForce(jointID)
  • Object.Physics::MouseJointTargetX(jointID)
  • Object.Physics::MouseJointTargetY(jointID)
Prismatic
  • Object.Physics::PrismaticJointAxisAngle(jointID)
  • Object.Physics::PrismaticJointMaxMotorForce(jointID)
  • Object.Physics::PrismaticJointMaximumTranslation(jointID)
  • Object.Physics::PrismaticJointMinimumTranslation(jointID)
  • Object.Physics::PrismaticJointMotorForce(jointID)
  • Object.Physics::PrismaticJointMotorSpeed(jointID)
  • Object.Physics::PrismaticJointReferenceAngle(jointID)
  • Object.Physics::PrismaticJointCurrentSpeed(jointID)
  • Object.Physics::PrismaticJointCurrentTranslation(jointID)
Pulley
  • Object.Physics::PulleyJointFirstGroundAnchorX(jointID)
  • Object.Physics::PulleyJointFirstGroundAnchorY(jointID)
  • Object.Physics::PulleyJointFirstLength(jointID)
  • Object.Physics::PulleyJointRatio(jointID)
  • Object.Physics::PulleyJointSecondGroundAnchorX(jointID)
  • Object.Physics::PulleyJointSecondGroundAnchorY(jointID)
  • Object.Physics::PulleyJointSecondLength(jointID)
Revolute
  • Object.Physics::RevoluteJointCurrentAngle(jointID)
  • Object.Physics::RevoluteJointMaximumAngle(jointID)
  • Object.Physics::RevoluteJointMaxMotorTorque(jointID)
  • Object.Physics::RevoluteJointMinimumAngle(jointID)
  • Object.Physics::RevoluteJointMotorSpeed(jointID)
  • Object.Physics::RevoluteJointMotorTorque(jointID)
  • Object.Physics::RevoluteJointReferenceAngle(jointID)
  • Object.Physics::RevoluteJointAngularSpeed(jointID)
Rope
  • Object.Physics::RopeJointMaxLength(jointID)
Weld
  • Object.Physics::WeldJointDampingRatio(jointID)
  • Object.Physics::WeldJointFrequency(jointID)
  • Object.Physics::WeldJointReferenceAngle(jointID)
Wheel
  • Object.Physics::WheelJointAxisAngle(jointID)
  • Object.Physics::WheelJointDampingRatio(jointID)
  • Object.Physics::WheelJointFrequency(jointID)
  • Object.Physics::WheelJointMaxMotorTorque(jointID)
  • Object.Physics::WheelJointMotorSpeed(jointID)
  • Object.Physics::WheelJointMotorTorque(jointID)
  • Object.Physics::WheelJointCurrentSpeed(jointID)
  • Object.Physics::WheelJointCurrentTranslation(jointID)

Global

  • Object.Physics::GravityX()
  • Object.Physics::GravityY()
  • Object.Physics::TimeScale()

Other functions in Physics Engine 2.0

  • Object.Physics::MassCenterX()
  • Object.Physics::MassCenterY()

Tween Animation

  • Object.TweenAnimation::Progress(“tweenIdentifier”)

(*) Native only

Some functions come from GD4 and are available only for native export

* Object 3D Box

  • Object.Depth()
  • Object.Pitch()
  • Object.Roll()
  • Object.Yaw()
  • Object.Z()

* Object Light

  • Object.Intensity()
  • Object.Quality()
  • Object.Radius()

* Automatism Automatic Network update

  • Object.NetworkUpdater::GetIdentifier()

* Automatism Path

  • Object.Path::AngleOffset()
  • Object.Path::PathX()
  • Object.Path::PathY()
  • Object.Path::Position()
  • Object.Path::Segment()
  • Object.Path::Speed()

* Object Sound

  • Object.Attenuation()
  • Object.MinDistance()
  • Object.Pitch()
  • Object.Volume()
  • Object.ZPos()

* Text Entry

  • TextEntryObject.String()

* Advanced XML

  • AdvancedXML::GetAttributeNumber(“ElementReference”,“AttrName”)
  • AdvancedXML::GetElementType(“ElementReference”)

* Network

  • Network::GetReceivedDataValue(“DataName”)

* Sound Object: Listener

  • SoundObject::ListenerDirectionX()
  • SoundObject::ListenerDirectionY()
  • SoundObject::ListenerDirectionZ()
  • SoundObject::ListenerX()
  • SoundObject::ListenerY()
  • SoundObject::ListenerZ()