This function can be used to switch on and off the standard debug overlay when testing your game and is disabled by default. The debug overlay shows a graphic CPU/GPU usage bar in the actual game window itself along with the current real fps value, number of texture swaps and the number of vertex batches (note that texture swaps and vertex batches will never be zero and will normally show values of 2 or 3, since even with an empty room an no objects GameMaker Studio 2 still has to draw and batch things).
这个显示栏被分成几个部分,每个部分代表 1/60 秒。As you can see from the image above, the bar is made up of various colours:
- 绿色 - 输入/输出处理(即:键盘,鼠标,游戏手柄,网络等)
- 红色 - 步事件的更新速度
- 黄色 - 绘制事件所需的时间
- Orange -Debug update time, which is only normally visible when you use the debug module
- 白色 - GPU 剩余时间,这是 GPU 在下一个画面可以开始渲染之前完成当前画面渲染所花费的时间
- 青色 - 文字渲染时间
- 灰色 - 清除屏幕每个绘制步骤所需的时间
- 深红色 - GPU 刷新,即 GPU 从存储器中清除图像所需的时间
Using this function you can add the overlay whether in debug mode or not, and in this way, you can see how efficiently your game runs and get a visual cue as to how it is using the available resources, without the over-head of having the debugger running alongside.
show_debug_overlay(enable);
参数 | 描述 |
---|---|
enable | switch on (true) or off (false) the debug overlay. |
N/A(无返回值)
if global.debug
{
show_debug_overlay(true);
}
else
{
show_debug_overlay(false);
}
The above code will toggle the debug on or off depending on the value of a global variable.