Skip to content

Expressions参考

表达式可以在看到带有以下按钮之一的字段时输入:

  • 左侧按钮表示“字符串表达式”(文本)
  • 右侧按钮表示“数值表达式”(数字)

Expressions

这个页面是按照扩展、对象或行为分组的 GDevelop 中可使用的所有表达式的参考。当写下 Object 时,您应该输入一个对象名称。在这里了解更多如何编写表达式的信息

提示

有时表达式也被称为函数,就像在数学中一样。

对象

这些是可用于 GDevelop 中所有对象的常见特征。阅读更多有关的解释

表达式

描述

PickedInstancesCount(object)

返回之前条件(或操作)选择的实例数量。

👾 Object

表达式

描述

Object.Angle()

对象的当前角度(以度为单位)

Object.AngleToObject(object)

计算两个对象之间的角度(以度为单位)。如果需要计算到任意位置的角度,请使用 AngleToPosition

👾 Object

表达式

描述

Object.AngleToPosition(number, number)

计算对象中心和“目标”位置之间的角度(以度为单位)。如果需要计算两个对象之间的角度,请使用 AngleToObject

🔢 Number

目标 X 位置

🔢 Number

目标 Y 位置

Object.ArrayVariableFirstNumber(object variable)

如果是数字变量,则获取对象数组变量的第一个元素的值。

🗄️ Object variable

数组变量

Object.ArrayVariableFirstString(object variable)

如果是文本(字符串)变量,则获取对象数组变量的第一个元素的值。

🗄️ Object variable

数组变量

Object.ArrayVariableLastNumber(object variable)

如果是数字变量,则获取对象数组变量的最后一个元素的值。

🗄️ Object variable

数组变量

Object.ArrayVariableLastString(object variable)

如果是文本(字符串)变量,则获取对象数组变量的最后一个元素的值。

🗄️ Object variable

数组变量

Object.BoundingBoxBottom()

返回包围对象的区域(边界框)底部位置。

Object.BoundingBoxCenterX()

返回包围对象的区域(边界框)中心 X 位置。

Object.BoundingBoxCenterY()

返回包围对象的区域(边界框)中心 Y 位置。

Object.BoundingBoxLeft()

返回包围对象的区域(边界框)左侧位置。

Object.BoundingBoxRight()

返回包围对象的区域(边界框)右侧位置。

Object.BoundingBoxTop()

返回包围对象的区域(边界框)顶部位置。

Object.CenterX()

返回旋转中心的 X 位置。

Object.CenterY()

返回旋转中心的 Y 位置。

Object.Distance(object)

两个对象之间的距离

👾 Object

对象

Object.DistanceToPosition(number, number)

对象和位置之间的距离

🔢 Number

目标 X 位置

🔢 Number

目标 Y 位置

Object.ForceAngle()

力的合力角度(以度为单位)

Object.ForceLength()

力的合力长度

Object.ForceX()

合力的 X 坐标

Object.ForceY()

合力的 Y 坐标

Object.Height()

对象的高度

Object.Layer()

返回对象所在图层的名称

Object.ObjectName()

返回对象的名称

Object.ObjectTimerElapsedTime(string)

对象定时器的值

🔤 Name (String)

定时器的名称

Object.SqDistance(object)

两个对象之间的平方距离

👾 Object

对象

Object.SqDistanceToPosition(number, number)

对象和位置之间的平方距离

🔢 Number

目标 X 位置

🔢 Number

目标 Y 位置

Object.Variable(object variable)

对象变量的数字值

🗄️ Object variable

变量

Object.VariableChildCount(object variable)

对象数组或结构变量中的子项数

🗄️ Object variable

数组或结构变量

Object.VariableString(object variable)

对象变量的文本

🗄️ Object variable

变量

Object.Width()

对象的宽度

Object.X()

对象的 X 位置

Object.XFromAngleAndDistance(number, number)

在给定起始对象的角度和距离的情况下计算 X 位置。这也被称为使用极坐标获取 2D 矢量的笛卡尔坐标。

🔢 Number

角度,以度为单位

🔢 Number

距离

Object.Y()

对象的 Y 位置

Object.YFromAngleAndDistance(number, number)

在给定起始对象的角度和距离的情况下计算 Y 位置。这也被称为使用极坐标获取 2D 矢量的笛卡尔坐标。

🔢 Number

角度,以度为单位

🔢 Number

距离

Object.ZOrder()

对象的 Z 轴顺序

精灵

可用于游戏中大多数元素的动画对象。阅读更多有关的解释

表达式

描述

Object.AnimationFrameCount()

对象当前动画中的帧数

Object.PointX(object point name)

点的 X 位置

🔤 Object Point Name (String)

点的名称

Object.PointY(object point name)

点的 Y 位置

🔤 Object Point Name (String)

点的名称

Object.Sprite()

对象动画的当前帧

转换

用于转换数字、文本和数量的表达式。阅读更多有关的解释Expression

Description

LargeNumberToString(number)

Convert the result of the expression to text, without using the scientific notation

🔢 Number

Expression to be converted to text

ObjectVarToJSON(object, object variable)

Convert an object variable to JSON

👾 Object

The object with the variable

🗄️ Object variable

The object variable to be stringified

ToDeg(number)

Converts the angle, expressed in radians, into degrees

🔢 Number

Angle, in radians

ToJSON(variable)

Convert a variable to JSON

🗄️ Any variable

The variable to be stringified

ToNumber(string)

Convert the text to a number

string

Text to convert to a number

ToRad(number)

Converts the angle, expressed in degrees, into radians

🔢 Number

Angle, in degrees

ToString(number)

Convert the result of the expression to text

🔢 Number

Expression to be converted to text


Variables

Actions, conditions and expressions to handle variables, from simple variables like the player score, the number of remaining lives to complex variables containing arbitrary data like an inventory or the result of a web request. Read more explanations about it.

Expression

Description

GlobalVariable(global variable)

Number value of a global variable

🗄️ Global variable

Name of the global variable

GlobalVariableChildCount(global variable)

Number of children in a global array or structure variable

🗄️ Global variable

Array or structure variable

GlobalVariableFirstNumber(global variable)

Value of the first element of a global array variable, if it is a number variable

🗄️ Global variable

Array variable

GlobalVariableFirstString(global variable)

Value of the first element of a global array variable, if it is a text (string) variable.

🗄️ Global variable

Array variable

GlobalVariableLastNumber(global variable)

Value of the last element of a global array variable, if it is a number variable

🗄️ Global variable

Array variable

GlobalVariableLastString(global variable)

Value of the last element of a global array variable, if it is a text (string) variable.

🗄️ Global variable

Array variable

GlobalVariableString(global variable)

Text of a global variable

🗄️ Global variable

Variable

SceneVariableFirstNumber(scene variable)

Get the value of the first element of a scene array variable, if it is a number.

🗄️ Scene variable

Array variable

SceneVariableFirstString(scene variable)

Get the value of the first element of a scene array variable, if it is a text (string).

🗄️ Scene variable

Array variable

SceneVariableLastNumber(scene variable)

Get the value of the last element of a scene array variable, if it is a number.

🗄️ Scene variable

Array variable

SceneVariableLastString(scene variable)

Get the value of the last element of a scene array variable, if it is a text (string).

🗄️ Scene variable

Array variable

Variable(scene variable)

Number value of a scene variable

🗄️ Scene variable

Variable

VariableChildCount(variable)

Number of children in a scene array or structure variable

🗄️ Any variable

Array or structure variable

VariableFirstNumber(variable)

Get the value of the first element of an array variable, if it is a number.

🗄️ Any variable

Array variable

VariableFirstString(variable)

Get the value of the first element of an array variable, if it is a text (string).

🗄️ Any variable

Array variable

VariableLastNumber(variable)

Get the value of the last element of an array variable, if it is a number.

🗄️ Any variable

Array variable

VariableLastString(variable)

Get the value of the last element of an array variable, if it is a text (string).

🗄️ Any variable

Array variable

VariableString(scene variable)

Text of a scene variable

🗄️ Scene variable

Variable


Mouse and touch

Conditions and actions to handle either the mouse or touches on touchscreen. By default, conditions related to the mouse will also handle the touches - so that it's easier to handle both in your game. You can disable this behavior if you want to handle them separately in different events. Read more explanations about it.

Expression

Description

CursorX(layer name, number)

Return the X position of the cursor or of a touch.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

CursorY(layer name, number)

Return the Y position of the cursor or of a touch.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

MouseWheelDelta()

Mouse wheel displacement

StartedTouchOrMouseCount()

The number of touches (including the mouse) that have just started on this frame. The touch identifiers can be accessed using StartedTouchOrMouseId().

StartedTouchOrMouseId(number)

The identifier of the touch or mouse that has just started on this frame. The number of touches can be accessed using StartedTouchOrMouseCount().

🔢 Number

Touch index

TouchX(number, layer name, number)

Return the X position of a specific touch.

🔢 Number

Touch identifier

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

TouchY(number, layer name, number)

Return the Y position of a specific touch.

🔢 Number

Touch identifier

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.


Keyboard

Allows your game to respond to keyboard input. Note that this does not work with on-screen keyboard on touch devices: use instead conditions related to touch when making a game for mobile/touchscreen devices. Read more explanations about it.

Expression

Description

LastPressedKey()

Get the name of the latest key pressed on the keyboard


场景

在游戏过程中操作和操纵场景的行为和条件。

表达式

描述

  • CurrentSceneName()

当前场景的名称

  • SceneLoadingProgress(场景名称)

返回场景背景资源加载的进度(介于0和1之间)。

- 🔤 场景名称(字符串)

计时器和时间

运行计时器、获取当前时间或修改时间尺度(游戏运行速度 - 对于慢动作效果很有用)的行为和条件。点击此处阅读更多解释。

表达式

描述

  • Time(字符串)

当前时间

- 🔤 字符串
- 小时:hour - 分钟:min - 秒:sec - 月份的第几天:mday - 自一月份开始的月数:mon - 自1900年起的年数:year - 自周日以来的天数:wday - 自1月1日以来的天数:yday - 时间戳(毫秒):timestamp
  • TimeDelta()

自上一帧渲染到屏幕上的时间间隔

  • TimeFromStart()

自场景开始以来经过的时间

  • TimeScale()

返回场景的时间尺度

  • TimerElapsedTime(字符串)

场景计时器的值

- 🔤 名称(字符串)

数学工具

一组可用于表达式中的数学函数。

表达式

描述

  • AngleBetweenPositions(数,数,数,数)

计算两个位置之间的角度(以度为单位)

- 🔢 数
- 第一个点X位置
- 🔢 数
- 第一个点Y位置
- 🔢 数
- 第二个点X位置
- 🔢 数
- 第二个点Y位置
  • AngleDifference(数,数)

两个角度之间的差异

- 🔢 数
- 第一个角度,以度为单位
- 🔢 数
- 第二个角度,以度为单位
  • DistanceBetweenPositions(数,数,数,数)

计算两个位置之间的距离

- 🔢 数
- 第一个点X位置
- 🔢 数
- 第一个点Y位置
- 🔢 数
- 第二个点X位置
- 🔢 数
- 第二个点Y位置
  • Pi()

圆周率π(3.1415...)

  • Random(数)

随机整数

- 🔢 数
- 最大值
  • RandomFloat(数)

随机浮点数

- 🔢 数
- 最大值
  • RandomFloatInRange(数,数)

范围内的随机浮点数

- 🔢 数
- 最小值
- 🔢 数
- 最大值
  • RandomInRange(数,数)

范围内的随机整数

- 🔢 数
- 最小值
- 🔢 数
- 最大值
  • RandomWithStep(数,数,数)

步长中的随机值

- 🔢 数
- 最小值
- 🔢 数
- 最大值
- 🔢 数
- 步长
  • XFromAngleAndDistance(数,数)

给定角度和距离相对原点(0;0)时的X位置

- 🔢 数
- 角度,以度为单位
- 🔢 数
- 距离
  • YFromAngleAndDistance(数,数)

给定角度和距离相对原点(0;0)时的Y位置

- 🔢 数
- 角度,以度为单位
- 🔢 数
- 距离
  • abs(数)

绝对值

- 🔢 数
- 表达式
  • acos(数)

反余弦,返回一个角度(弧度)。ToDeg允许将其转换为度数。

- 🔢 数
- 表达式
  • acosh(数)

反双曲余弦

- 🔢 数
- 表达式
  • asin(数)

反正弦,返回一个角度(弧度)。ToDeg允许将其转换为度数。

- 🔢 数
- 表达式
  • asinh(数)

反双曲正弦

- 🔢 数
- 表达式
  • atan(数)

反正切,返回一个角度(弧度)。ToDeg允许将其转换为度数。

- 🔢 数
- 表达式
  • atan2(数,数)

2参数反正切(atan2)

- 🔢 数
- Y
- 🔢 数
- X
  • atanh(数)

反双曲正切

- 🔢 数
- 表达式
  • cbrt(数)

立方根

- 🔢 数
- 表达式
  • ceil(数)

将数字向上取整到整数

- 🔢 数
- 表达式
  • ceilTo(数,数)

将数字向上取整到小数点后第N位

- 🔢 数
- 表达式
- 🔢 数
- 表达式 (可选)
  • clamp(数,数,数)

将值限制在给定范围内

- 🔢 数
- 值
- 🔢 数
- 最小值
- 🔢 数
- 最大值
  • cos(数)

角度的余弦(以弧度为单位)。如果要使用度数,请使用ToRadsin(ToRad(45))

- 🔢 数
- 表达式
  • cosh(数)

双曲余弦

- 🔢 数
- 表达式
  • cot(数)

余切

- 🔢 数
- 表达式
  • csc(数)

余割

- 🔢 数
- 表达式
  • exp(数)

指数

- 🔢 数
- 表达式
  • floor(数)

将数字向下取整到整数

- 🔢 数
- 血拆表达式
  • floorTo(数,数)

将数字向下取整到小数点后第N位

- 🔢 数
- 表达式
- 🔢 数
- 表达式 (可选)
  • lerp(数,数,数)

线性插值从a到b为x

- 🔢 数
- a(在a+(b-a)*x中的a)
- 🔢 数
- b(在a+(b-a)*x中的b)
- 🔢 数
- x(在a+(b-a)*x中的x)
  • lerpAngle(数,数,数)

在两个角度之间进行线性插值(以度为单位),沿着圆圈朝最短方向。

- 🔢 数
- 起始角度,以度为单位
- 🔢 数
- 目标角度,以度为单位
- 🔢 数
- 0和1之间的插值
  • log(数)

对数

- 🔢 数
- 表达式
  • log10(数)

以10为底对数

- 🔢 数
- 表达式
  • log2(数)

以2为底对数

- 🔢 数
- 表达式
  • max(数,数)

两个数中的最大值

- 🔢 数
- 第一个表达式
- 🔢 数
- 第二个表达式
  • min(数,数)

两个数中的最小值

- 🔢 数
- 第一个表达式
- 🔢 数
- 第二个表达式
  • mod(数,数)

x mod y

- 🔢 数
- x(如x mod y)
- 🔢 数
- y(如x mod y)
  • normalize(数,数,数)

将值重新映射为0到1之间。

- 🔢 数
- 值
- 🔢 数
- 最小值
- 🔢 数
- 最大值
  • nthroot(数,数)

一个数字的N次根

- 🔢 数
- 数字
- 🔢 数
- N
  • pow(数,数)

将一个数字提高到幂

- 🔢 数
- 数字
- 🔢 数
- 幂(“x的幂n”中的n)
  • round(数)

Round a number

🔢 Number

Expression

roundTo(number, number)

Round a number to the Nth decimal place

🔢 Number

Expression

🔢 Number

Expression Optional.

sec(number)

Secant

🔢 Number

Expression

sign(number)

Return the sign of a number (1,-1 or 0)

🔢 Number

Expression

sin(number)

Sine of an angle (in radian). If you want to use degrees, useToRad: sin(ToRad(45)).

🔢 Number

Expression

sinh(number)

Hyperbolic sine

🔢 Number

Expression

sqrt(number)

Square root of a number

🔢 Number

Expression

tan(number)

Tangent of an angle (in radian). If you want to use degrees, useToRad: tan(ToRad(45)).

🔢 Number

Expression

tanh(number)

Hyperbolic tangent

🔢 Number

Expression

trunc(number)

Truncate a number

🔢 Number

Expression


Layers and cameras

Each scene can be composed of multiple layers. These conditions and actions allow to manipulate them during the game. In particular, you can move the camera of a layer to center it on an object or a position. Read more explanations about it.

Expression

Description

CameraAngle(layer name, number)

Return the angle of rotation of a camera (in degrees).

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

CameraBorderBottom(layer name, number)

Return the position of the bottom border of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraBorderLeft(layer name, number)

Return the position of the left border of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraBorderRight(layer name, number)

Return the position of the right border of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraBorderTop(layer name, number)

Return the position of the top border of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraCenterX(layer name, number)

Return the X position of the center of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

CameraCenterY(layer name, number)

Return the Y position of the center of a camera.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

CameraHeight(layer name, number)

Return the height of a camera of a layer.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraWidth(layer name, number)

Return the width of a camera of a layer.

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number Optional.

CameraZoom(layer name, number)

Zoom of a camera of a layer

🔤 Layer name (String)

Layer Optional.

🔢 Number

Camera number (default : 0) Optional.

LayerDefaultZOrder(layer name)

Default Z Order for a layer

🔤 Layer name (String)

Layer

LayerTimeScale(layer name)

Returns the time scale of the specified layer.

🔤 Layer name (String)

Layer


Sounds and music

GDevelop provides several conditions and actions to play audio files. They can be either long music or short sound effects. Read more explanations about it.

Expression

Description

GlobalVolume()

Global volume value

MusicChannelPitch(number)

Music's pitch

🔢 Number

Channel

MusicChannelPlayingOffset(number)

Music playing offset

🔢 Number

Channel

MusicChannelVolume(number)

Music volume

🔢 Number

Channel

SoundChannelPitch(number)

Sound's pitch

🔢 Number

Channel

SoundChannelPlayingOffset(number)

Sound playing offset

🔢 Number

Channel

SoundChannelVolume(number)

Sound volume

🔢 Number

Channel


Game window and resolution

Provides actions and conditions to manipulate the game window. Depending on the platform on which the game is running, not all of these features can be applied. Read more explanations about it.

Expression

Description

SceneWindowHeight()

Height of the scene window (or scene canvas for HTML5 games)

SceneWindowWidth()

Width of the scene window (or scene canvas for HTML5 games)

ScreenHeight()

Height of the screen (or the page for HTML5 games in browser)

ScreenWidth()

Width of the screen (or the page for HTML5 games in browser)

WindowTitle()

Window's title


Text manipulation

Provides expressions to manipulate strings (also called texts).

Expression

Description

FromCodePoint(number)

Get character from code point

🔢 Number

Code point

NewLine()

Insert a new line

StrAt(string, number)

Get a character from a text

string

Text

🔢 Number

Position of the character (the first letter is at position 0)

StrFind(string, string)

Search in a text (return the position of the result or -1 if not found)

string

Text

string

Text to search for

StrFindFrom(string, string, number)

Search in a text, starting from a position (return the position of the result or -1 if not found)

string

Text

string

Text to search for

🔢 Number

Position of the first character in the string to be considered in the search

StrFindLast(string, string)

Search the last occurrence in a string (return the position of the result, from the beginning of the string, or -1 if not found)

string

Text

string

Text to search for

StrFindLastFrom(string, string, number)

Search in a text the last occurrence, starting from a position (return the position of the result, from the beginning of the string, or -1 if not found)

string

Text

string

Text to search for

🔢 Number

Position of the last character in the string to be considered in the search

StrLength(string)

Length of a text

文本

StrRepeat(string, number)

重复文本

文本

要重复的文本

🔢 数字

重复次数

SubStr(string, number, number)

获取文本的一部分

文本

文本

🔢 数字

部分的起始位置(第一个字母的位置为0)

🔢 数字

部分的长度

ToLowerCase(string)

将文本转为小写

文本

ToUpperCase(string)

将文本转为大写

文本


可动画化能力

对对象进行动画化。阅读更多解释。

表达式

描述

Object.Animation::Duration()

返回当前动画的持续时间(秒)。

Object.Animation::ElapsedTime()

返回从动画开始时经过的时间(秒)。

Object.Animation::Index()

返回对象使用动画编号(来自动画列表的动画)播放的动画。

Object.Animation::Name()

使用动画的名称返回对象播放的动画。

Object.Animation::SpeedScale()

返回动画速度比例(1 = 默认速度,>1 = 更快,<1 = 更慢)。


效果能力

将视觉效果应用于对象。阅读更多解释。

此行为没有表达式。


可翻转能力

翻转对象。阅读更多解释。

此行为没有表达式。


可调整大小能力

改变对象的尺寸。阅读更多解释。

此行为没有表达式。


可缩放能力

改变对象的缩放比例。阅读更多解释。

表达式

描述

Object.Scale::Value()

返回对象的缩放比例(默认比例为1)。

Object.Scale::X()

返回对象在X轴上的缩放比例(默认比例为1)。

Object.Scale::Y()

返回对象在Y轴上的缩放比例(默认比例为1)。


不透明能力

改变对象的不透明度。阅读更多解释。

表达式

描述

Object.Opacity::Value()

返回对象的不透明度,范围从0(完全透明)到255(不透明)。


文本能力

访问对象文本。阅读更多解释。

表达式

描述

Object.Text::Value()

返回文本。


平台(来自扩展平台行为)

将对象标记为可供角色奔跑的平台。阅读更多解释。

此行为没有表达式。

平台式角色(来自扩展平台行为)

在平台上跳跃奔跑。阅读更多解释。

表达式

描述

Object.PlatformerObject::Acceleration()

返回对象的水平加速度(每秒每秒的像素)。

Object.PlatformerObject::CurrentFallSpeed()

返回对象的当前下落速度(每秒的像素)。其值始终为正值。

Object.PlatformerObject::CurrentJumpSpeed()

返回对象的当前跳跃速度(每秒的像素)。其值始终为正值。

Object.PlatformerObject::CurrentSpeed()

返回对象的当前水平速度(每秒的像素)。对象向左移动的值为负值,向右移动的值为正值。

Object.PlatformerObject::Deceleration()

返回对象的水平减速度(每秒每秒的像素)。

Object.PlatformerObject::Gravity()

返回对象上施加的重力(每秒每秒的像素)。

Object.PlatformerObject::JumpSpeed()

返回对象的跳跃速度(每秒的像素)。其值始终为正值。

Object.PlatformerObject::JumpSustainTime()

返回对象的跳跃维持时间(秒)。这是保持跳跃按钮按下时,初始跳跃速度保持不变的时间。

Object.PlatformerObject::LadderClimbingSpeed()

返回对象的梯子爬升速度(每秒的像素)。

Object.PlatformerObject::MaxFallingSpeed()

返回对象的最大下落速度(每秒的像素)。

Object.PlatformerObject::MaxSpeed()

返回对象的最大水平速度(每秒的像素)。


在屏幕外销毁(来自销毁超出屏幕行为扩展)

当物体超出屏幕边界时自动销毁物体。阅读更多解释。

此行为没有表达式。


平铺精灵(来自平铺精灵对象扩展)

在一个区域上重复显示图像。阅读更多解释。

表达式

描述

Object.XOffset()

返回在显示图像时在X轴上使用的偏移量。

Object.YOffset()

返回在显示图像时在Y轴上使用的偏移量。


可拖动对象(来自拖动行为扩展)

通过按住鼠标按钮(或触摸)移动对象。阅读更多解释。

此行为没有表达式。


自上而下移动(4或8个方向)(来自自上而下移动扩展)Move objects left, up, right, and down (and, optionally, diagonally). 点击此处阅读更多关于它的解释。

表达式

说明

Object.TopDownMovement::Acceleration()

对象的加速度

Object.TopDownMovement::Angle()

移动的角度(以度为单位)

Object.TopDownMovement::AngleOffset()

应用于对象的旋转偏移

Object.TopDownMovement::AngularMaxSpeed()

对象的角速度最大值

Object.TopDownMovement::Deceleration()

对象的减速度

Object.TopDownMovement::MaxSpeed()

对象的最大速度

Object.TopDownMovement::MovementAngleOffset()

返回移动角度偏移。

Object.TopDownMovement::Speed()

对象的速度

Object.TopDownMovement::StickAngle()

返回模拟杆输入的角度(以度为单位)

Object.TopDownMovement::XVelocity()

移动在X轴上的速度

Object.TopDownMovement::YVelocity()

移动在Y轴上的速度


文本(从扩展文本对象)

在屏幕上显示文本。点击此处阅读更多关于它的解释。

表达式

说明

Object.FontSize()

返回文本对象的字体大小。

Object.OutlineThickness()

返回文本的轮廓厚度。

Object.Padding()

填充

Object.ShadowAngle()

返回文本阴影的角度。

Object.ShadowBlurRadius()

返回文本阴影的模糊半径。

Object.ShadowDistance()

返回文本阴影的距离。

Object.ShadowOpacity()

返回文本阴影的不透明度。


粒子发射器(来自扩展粒子系统)

显示大量小粒子以创建视觉效果。点击此处阅读更多关于它的解释。

表达式

说明

Object.ConeSprayAngle()

喷射锥的角度

Object.CurrentParticleCount()

当前显示的粒子数。

Object.EmitterAngle()

粒子的发射角度。

Object.EmitterForceMax()

粒子的最大发射力。

Object.EmitterForceMin()

粒子的最小发射力。

Object.Flow()

粒子的流量(每秒粒子数)。

Object.MaxParticlesCount()

返回显示的最大粒子数。

Object.ParticleAlpha1()

粒子的起始不透明度。

Object.ParticleAlpha2()

粒子的结束不透明度。

Object.ParticleBlue1()

粒子的起始蓝色成分。

Object.ParticleBlue2()

粒子的结束蓝色成分。

Object.ParticleGravityAngle()

重力角度。

Object.ParticleGravityLength()

重力值。

Object.ParticleGravityX()

作用在X轴上的粒子重力。

Object.ParticleGravityY()

作用在Y轴上的粒子重力。

Object.ParticleGreen1()

粒子的起始绿色成分。

Object.ParticleGreen2()

粒子的结束绿色成分。

Object.ParticleLifeTimeMax()

粒子的最大寿命。

Object.ParticleLifeTimeMin()

粒子的最小寿命。

Object.ParticleRed1()

粒子的起始红色成分。

Object.ParticleRed2()

粒子的结束红色成分。

Object.ParticleRotationMaxSpeed()

返回粒子的最大旋转速度。

Object.ParticleRotationMinSpeed()

返回粒子的最小旋转速度。

Object.ParticleSize1()

粒子的初始大小。

Object.ParticleSize2()

粒子的结束大小。

Object.RendererParam1()

渲染的第一个参数

Object.RendererParam2()

渲染的第二个参数

Object.Tank()

粒子容量。

Object.Texture()

粒子显示的图像的名称。

Object.ZoneRadius()

发射区域的半径。


面板精灵(“9块”)(来自扩展面板精灵(9块)对象)

一个带有单独拉伸边缘和角落部分的图像。点击此处阅读更多关于它的解释。

此对象没有表达式。


锚点

将对象锚定到窗口边界。点击此处阅读更多关于它的解释。

此行为没有表达式。


形状绘制器

允许您在屏幕上使用事件绘制简单的形状。点击此处阅读更多关于它的解释。

表达式

说明

Object.Antialiasing()

返回正在使用的抗锯齿类型:无,低,中或高。

Object.FillColorBlue()

填充颜色的蓝色分量

Object.FillColorGreen()

填充颜色的绿色分量

Object.FillColorRed()

填充颜色的红色分量

Object.FillOpacity()

填充不透明度

Object.OutlineColorBlue()

轮廓颜色的蓝色分量

Object.OutlineColorGreen()

轮廓颜色的绿色分量

Object.OutlineColorRed()

轮廓颜色的红色分量

Object.OutlineOpacity()

轮廓不透明度

Object.OutlineSize()

轮廓大小

Object.ToDrawingX(数字,数字)

从场景绘制点的X绘制坐标

🔢 数字

X场景位置

🔢 数字

Y场景位置

Object.ToDrawingY(数字,数字)

从场景绘制点的Y绘制坐标

🔢 数字

X场景位置

🔢 数字

Y场景位置

Object.ToSceneX(数字,数字)

从绘图的X场景坐标

🔢 数字

X绘图位置

🔢 数字

Y绘图位置

Object.ToSceneY(数字,数字)

从绘图的Y场景坐标

🔢 数字

X绘图位置

🔢 数字

Y绘图位置


文字输入(来自扩展文字输入对象)

用于获取使用键盘输入的文本的不可见对象。点击此处阅读更多关于它的解释。## 表达式

描述

Object.String()

键盘输入的文本


库存

提供将库存添加到游戏中的操作和条件,其中包含内存中的物品。了解更多关于库存的解释。

表达式

描述

Inventory::Count(string, string)

获取库存中物品的数量

string

库存名称

string

物品名称

Inventory::Maximum(string, string)

获取库存中物品的最大数量,如果无限则返回0

string

库存名称

string

物品名称


寻路(来自路径查找行为扩展)

将对象移动到目标位置,同时避开所有标记为障碍物的对象。了解更多关于路径查找的解释。

表达式

描述

Object.Pathfinding::Acceleration()

对象在路径上的加速度

Object.Pathfinding::AngleOffset()

对象在路径上施加的旋转偏移

Object.Pathfinding::AngularMaxSpeed()

对象在路径上的角速度

Object.Pathfinding::CellHeight()

虚拟网格的高度

Object.Pathfinding::CellWidth()

虚拟网格的宽度

Object.Pathfinding::DestinationX()

目标X位置

Object.Pathfinding::DestinationY()

目标Y位置

Object.Pathfinding::ExtraBorder()

在路径上施加的额外边界

Object.Pathfinding::GetNodeX(number)

获取下一个路标的X位置

🔢 数字

节点索引(从0开始!)

Object.Pathfinding::GetNodeY(number)

获取下一个路标的Y位置

🔢 数字

节点索引(从0开始!)

Object.Pathfinding::GridOffsetX()

返回虚拟网格的X偏移

Object.Pathfinding::GridOffsetY()

返回虚拟网格的Y偏移

Object.Pathfinding::LastNodeX()

最后一个路标的X位置

Object.Pathfinding::LastNodeY()

最后一个路标的Y位置

Object.Pathfinding::MaxSpeed()

对象在路径上的最大速度

Object.Pathfinding::MovementAngle()

在路径上移动的角度

Object.Pathfinding::NextNodeIndex()

获取要到达的下一个路标的索引

Object.Pathfinding::NextNodeX()

获取下一个路标的X位置

Object.Pathfinding::NextNodeY()

获取下一个路标的Y位置

Object.Pathfinding::NodeCount()

获取路径上的路标数量

Object.Pathfinding::Speed()

对象在路径上的速度

路径查找的障碍物(来自路径查找行为扩展)

标记对象为路径查找的障碍物。了解更多关于路径查找的解释。

表达式

描述

Object.PathfindingObstacle::Cost()

障碍物的成本


物理引擎(来自物理引擎(已弃用)扩展)

使对象按照物理定律移动。如果您正在创建新游戏,请优先使用物理引擎 2.0 了解更多关于物理引擎的解释。

表达式

描述

Object.Physics::AngularDamping()

角阻尼

Object.Physics::AngularVelocity()

角速度

Object.Physics::LinearDamping()

线性阻尼

Object.Physics::LinearVelocity()

线性速度

Object.Physics::LinearVelocityX()

X 分量

Object.Physics::LinearVelocityY()

Y 分量

Object.Physics::PolygonScaleX()

碰撞多边形 X 缩放

Object.Physics::PolygonScaleY()

碰撞多边形 Y 缩放


3D

支持 GDevelop 中的 3D 功能。

表达式

描述

Scene3D::CameraFarPlane(layer name, number)

返回相机远平面距离。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

Scene3D::CameraFov(layer name, number)

返回相机视场角度。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

Scene3D::CameraNearPlane(layer name, number)

返回相机近平面距离。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

Scene3D::CameraRotationX(layer name, number)

返回相机在 X 轴上的旋转。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

Scene3D::CameraRotationY(layer name, number)

返回相机在 Y 轴上的旋转。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

Scene3D::CameraZ(layer name, number)

返回相机在 Z 轴上的位置。

🔤 层名称(字符串)

图层 可选

🔢 数字

相机编号(默认值:0)可选

3D 立方体(来自 3D 扩展)

一个具有每个面的图像的立方体

此对象没有表达式。

3D 模型(来自 3D 扩展)

一个带动画的 3D 模型。

此对象没有表达式。

3D 能力(来自 3D 扩展)

在 3D 空间中移动对象。

表达式

描述

Object.Object3D::CenterZ()

返回旋转中心的 Z 位置。

Object.Object3D::Depth()

返回深度(Z 轴上的大小)。

Object.Object3D::RotationX()

返回 X 轴上的旋转。

Object.Object3D::RotationY()

返回 Y 轴上的旋转。

Object.Object3D::ScaleZ()

返回对象的 Z 轴比例(默认比例为 1)。

Object.Object3D::Z()

返回 Z 位置(“海拔”)。


高级窗口管理

提供与游戏窗口定位和操作系统交互相关的高级功能。

表达式

描述

AdvancedWindow::WindowOpacity()

返回当前窗口的不透明度(从0到1的数字,1为完全不透明)。

AdvancedWindow::WindowX()

返回当前窗口的 X 位置。

AdvancedWindow::WindowY()

返回当前窗口的 Y 位置。

Returns the file name from the given file path.返回带有扩展名的文件名。Get the linear velocity angle of an object.

Object.Physics2::LinearVelocityX()

Get the linear velocity of an object on X axis.

Object.Physics2::LinearVelocityY()

Get the linear velocity of an object on Y axis.

Object.Physics2::Mass()

Return the mass of the object (in kilograms)

Object.Physics2::MassCenterX()

Mass center X

Object.Physics2::MassCenterY()

Mass center Y

Object.Physics2::MotorJointAngularOffset(number)

Motor joint angular offset

🔢 Number

Joint ID

Object.Physics2::MotorJointCorrectionFactor(number)

Motor joint correction factor

🔢 Number

Joint ID

Object.Physics2::MotorJointMaxForce(number)

Motor joint maximum force

🔢 Number

Joint ID

Object.Physics2::MotorJointMaxTorque(number)

Motor joint maximum torque

🔢 Number

Joint ID

Object.Physics2::MotorJointOffsetX(number)

Motor joint offset X

🔢 Number

Joint ID

Object.Physics2::MotorJointOffsetY(number)

Motor joint offset Y

🔢 Number

Joint ID

Object.Physics2::MouseJointDampingRatio(number)

Mouse joint damping ratio

🔢 Number

Joint ID

Object.Physics2::MouseJointFrequency(number)

Mouse joint frequency

🔢 Number

Joint ID

Object.Physics2::MouseJointMaxForce(number)

Mouse joint maximum force

🔢 Number

Joint ID

Object.Physics2::MouseJointTargetX(number)

Mouse joint target X

🔢 Number

Joint ID

Object.Physics2::MouseJointTargetY(number)

Mouse joint target Y

🔢 Number

Joint ID

Object.Physics2::PrismaticJointAxisAngle(number)

Prismatic joint axis angle

🔢 Number

Joint ID

Object.Physics2::PrismaticJointMaxMotorForce(number)

Prismatic joint maximum motor force

🔢 Number

Joint ID

Object.Physics2::PrismaticJointMaxTranslation(number)

Prismatic joint maximum translation

🔢 Number

Joint ID

Object.Physics2::PrismaticJointMinTranslation(number)

Prismatic joint minimum translation

🔢 Number

Joint ID

Object.Physics2::PrismaticJointMotorForce(number)

Prismatic joint motor force

🔢 Number

Joint ID

Object.Physics2::PrismaticJointMotorSpeed(number)

Prismatic joint motor speed

🔢 Number

Joint ID

Object.Physics2::PrismaticJointReferenceAngle(number)

Prismatic joint reference angle

🔢 Number

Joint ID

Object.Physics2::PrismaticJointSpeed(number)

Prismatic joint speed

🔢 Number

Joint ID

Object.Physics2::PrismaticJointTranslation(number)

Prismatic joint current translation

🔢 Number

Joint ID

Object.Physics2::PulleyJointFirstGroundAnchorX(number)

Pulley joint first ground anchor X

🔢 Number

Joint ID

Object.Physics2::PulleyJointFirstGroundAnchorY(number)

Pulley joint first ground anchor Y

🔢 Number

Joint ID

Object.Physics2::PulleyJointFirstLength(number)

Pulley joint first length

🔢 Number

Joint ID

Object.Physics2::PulleyJointRatio(number)

Pulley joint ratio

🔢 Number

Joint ID

Object.Physics2::PulleyJointSecondGroundAnchorX(number)

Pulley joint second ground anchor X

🔢 Number

Joint ID

Object.Physics2::PulleyJointSecondGroundAnchorY(number)

Pulley joint second ground anchor Y

🔢 Number

Joint ID

Object.Physics2::PulleyJointSecondLength(number)

Pulley joint second length

🔢 Number

Joint ID

Object.Physics2::Restitution()

Get the restitution of an object.

Object.Physics2::RevoluteJointAngle(number)

Revolute joint current angle

🔢 Number

Joint ID

Object.Physics2::RevoluteJointMaxAngle(number)

Revolute joint maximum angle

🔢 Number

Joint ID

Object.Physics2::RevoluteJointMaxMotorTorque(number)

Revolute joint maximum motor torque

🔢 Number

Joint ID

Object.Physics2::RevoluteJointMinAngle(number)

Revolute joint minimum angle

🔢 Number

Joint ID

Object.Physics2::RevoluteJointMotorSpeed(number)

Revolute joint motor speed

🔢 Number

Joint ID

Object.Physics2::RevoluteJointMotorTorque(number)

Revolute joint motor torque

🔢 Number

Joint ID

Object.Physics2::RevoluteJointReferenceAngle(number)

Revolute joint reference angle

🔢 Number

Joint ID

Object.Physics2::RevoluteJointSpeed(number)

Revolute joint angular speed

🔢 Number

Joint ID

Object.Physics2::RopeJointMaxLength(number)

Rope joint maximum length

🔢 Number

Joint ID

Object.Physics2::TimeScale()

World time scale

Object.Physics2::WeldJointDampingRatio(number)

Weld joint damping ratio

🔢 Number

Joint ID

Object.Physics2::WeldJointFrequency(number)

Weld joint frequency

🔢 Number

Joint ID

Object.Physics2::WeldJointReferenceAngle(number)

Weld joint reference angle

🔢 Number

Joint ID

Object.Physics2::WheelJointAxisAngle(number)

Wheel joint axis angle

🔢 Number

Joint ID

Object.Physics2::WheelJointDampingRatio(number)

Wheel joint damping ratio

🔢 Number

Joint ID

Object.Physics2::WheelJointFrequency(number)

Wheel joint frequency

🔢 Number

Joint ID

Object.Physics2::WheelJointMaxMotorTorque(number)

Wheel joint maximum motor torque

🔢 Number

Joint ID

Object.Physics2::WheelJointMotorSpeed(number)

Wheel joint motor speed

🔢 Number

Joint ID

Object.Physics2::WheelJointMotorTorque(number)

Wheel joint motor torque

🔢 Number

Joint ID

Object.Physics2::WheelJointSpeed(number)

Wheel joint speed

🔢 Number

Joint ID

Object.Physics2::WheelJointTranslation(number)

Wheel joint current translation

🔢 Number

Joint ID


Player Authentication

Allow your game to authenticate players. Read more explanations about it.

Expression

Description

PlayerAuthentication::UserID()

Get the unique user ID of the authenticated player.

PlayerAuthentication::Username()

Get the username of the authenticated player.


Spine (experimental)

Display and smoothly animate a 2D object with skeletal animations made with Spine. Use files exported from Spine (json, atlas and image). Read more explanations about it.

Object.Animation()

返回两个动画之间平滑过渡的持续时间(以秒为单位)。🔤 名称 (字符串)

Tween 标识符

平滑地动画化对象的位置、角度、缩放和其他属性。对其进行更多解释。

表达式

描述

Object.Tween::Progress(string)

返回缓动的进度(介于 0.0 和 1.0 之间)。

🔤 名称 (字符串)

Tween 标识符

Object.Tween::Value(string)

返回缓动的值。对于具有多个值的缓动,该值始终为 0。

🔤 名称 (字符串)

Tween 标识符


视频

显示视频。对其进行更多解释。

表达式

描述

Object.CurrentTime()

返回视频对象的当前时间(以秒为单位)。

Object.Duration()

返回视频对象的持续时间(以秒为单位)。

Object.PlaybackSpeed()

返回视频对象的播放速度

Object.Volume()

获取视频对象的音量,范围在 0(静音)和 100(最大)之间。