debug_event

此函数生成一个自定义调试事件,当游戏在调试模式下运行时,该事件将显示在调试器的图表查看中。如果您需要在调试模式下在而不是时显示消息,请使用 show_debug_message

该函数还将接受五个保留字符串,以帮助使用外部应用程序(如Visual Studio)执行调试。这些字符串是:

 

ResourceCountsResourceCounts 资源计数

当您使用 "ResourceCounts" 参数调用 debug_event 时,它将返回一个结构,其中包含有关游戏中所有活动资源的信息。

每个资源都用三个属性表示:

该结构具有以下成员:

 

DumpMemory DumpMemory 转储内存

当您使用 "DumpMemory" 参数调用 debug_event 时,它将返回一个结构,其中包含有关游戏内存使用的信息。

结构的成员将根据平台的不同而有所不同,但是所有平台在结构中至少具有以下值(以字节为单位):

The way these values are measured is different on each platform. Note that this can only show the memory that the runner is in control of, and so the values here may be different than e.g. the values shown in the OS, which may sometimes be higher, as some systems may add overhead that this function cannot track in a platform-agnostic manner.

 

语法:

debug_event(string, [silent]);

参数类型描述
stringString要使用的自定义调试事件字符串或五个保留字符串之一。
silentBoolean可选 此参数使函数以结构形式将结果静默返回给运行器,而不是将值打印到控制台。默认为 false

 

返回:

Struct (for some options) or N/A

 

示例1:自定义字符串

if (!surface_exists(global.EffectsSurface))
{
    debug_event("Recreating Effects Surface");
    global.EffectsSurface = surface_create(room_width, room_height);
}

上面的代码检查表面是否存在,如果不存在,则在调试器的图形视图中触发调试事件(游戏必须在调试模式下运行才能显示),并重新创建表面。

 

示例2:保留字符串

var _counts = debug_event("ResourceCounts");

上面的代码触发了一个调试事件,消息为 "ResourceCounts"。因为这是一个保留字符串,所以资源计数被输出到控制台,并且也在结构中返回。此结构存储在临时变量 _counts 中。要禁止输出到控制台,请将第二个参数设置为 true

var _counts = debug_event("ResourceCounts", true);