此函数在运行时在 输出窗口 和 调试覆盖层 中显示自定义调试消息。
此函数的语法与 string 函数的语法相同除了单个参数外,它还可以接受带有占位符的格式字符串以及用来替换占位符的其他参数。
Real 类型为整数的值在字符串中不会有小数位。具有小数部分的 Real 类型的值在字符串中有两个小数位。如果在输出字符串中需要更多的小数位,可以使用函数string_format。
Values of type Struct or Instance will be converted to a string using that struct's or instance's toString() Method if one exists, or converted to a string implicitly.
Values of type Handle will be converted to a string that shows the handle info: "ref <type> <id>".
Values of type Array will be converted to a string of the format [element1, element2, element3, element4, element5], i.e. the concatenation of all elements in the array. If any of the elements in the array is a struct or an instance then its will be called to convert it to a string.
在调试模式下运行游戏时,使用此函数显示的调试消息将显示在IDE底部的编译器输出窗口以及调试器的图形视图中。如果您只想在调试模式下查看消息,那么您可能应该使用debug_event()。
show_debug_message(value_or_format [, value1, value2, ... max_val]);
参数 | 类型 | 描述 |
---|---|---|
value_or_format | Any (if value) or String (if format) | 要转换为字符串的值。 |
[, value1, value2, ... max_val] | Any | 可选 要插入占位符位置的值。 |
N/A
if (!instance_exists(obj_Exit))
{
show_debug_message("Exit not created!");
show_debug_message("Error Num: {0}", global.error);
game_end();
}
上面的代码检查实例是否存在,如果不存在,则在编译窗口中显示调试消息并结束游戏。