gpt4 book ai didi

debugging - GameMaker Studio - 不存在的表面

转载 作者:行者123 更新时间:2023-12-03 07:50:07 25 4
gpt4 key购买 nike

我目前正在完善我在 GameMaker Studio 中创建的引擎。目前,我正在为我的引擎添加阴影和平滑效果。

当我添加这些阴影时,我遇到了一个问题,并且能够将问题缩小到一行代码:
window_set_size(width, height);
我已将宽度设置为 1024,将高度设置为 600。但这不是问题。问题是,当我运行/调试我的游戏时,我以某种方式调用了如下所述的错误:

ERROR in
action number 1
of Step Event2
for object oGame:

Trying to use non-existing surface.
at gml_Script_lsys_update (line 58) -
draw_surface_ext(global._lsys_light_surface[i], global._lsys_light_xpos[i] - global._lsys_light_radius[i], global._lsys_light_ypos[i] - global._lsys_light_radius[i], 1, 1, 0, global._lsys_light_color[i], 1);
----------------------------------------------------------------------------
stack frame is
gml_Script_lsys_update (line 58)
called from - gml_Object_oGame_StepEndEvent_1 (line 1) - lsys_update(alpha);

我是什么 非常松散相信这意味着,在我的窗口表面上绘图,不知何故与设置实际窗口本身的分辨率发生冲突。我还在下面的错误日志中包含了您正在阅读的脚本和命令:

lsys_update
draw_surface_ext(global._lsys_light_surface[i], global._lsys_light_xpos[i] - global._lsys_light_radius[i], global._lsys_light_ypos[i] - global._lsys_light_radius[i], 1, 1, 0, global._lsys_light_color[i], 1);

全局变量
global._lsys_lights = 0;
global._lsys_casters = 0;
global._lsys_quality = max(10/max(room_width, room_height), argument0);
global._lsys_surface = surface_create(room_width * global._lsys_quality, room_height * global._lsys_quality);

oGame End-Step 事件
lsys_update(alpha); // Alpha is set to an Integer value of 0.5
surface_reset_target();

我该如何消除这个错误并修复我的游戏?

任何帮助将是 很多赞赏。如果您需要更多信息,请发表评论。

最佳答案

记得在使用前检查表面是否仍然存在,使用 surface_exists ,如果它已从内存中消失,则重新创建它。

来自 documentation :

First, you should realise that surfaces (except the application surface) are "volatile". This means that if the device or window loses focus or is minimised (good examples are when a screensaver comes up in Windows, or on an Android device when the app loses focus due to a call) then the surface may be destroyed. This is because it is stored in the texture memory and may be overwritten when the target platform needs that memory for something else which means that you should always have some type of fail-safe code in place, usually with the surface_exists function.

关于debugging - GameMaker Studio - 不存在的表面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30683813/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com