surface_resize


语法:

surface_resize(surface_id, w, h);

参数 描述
surface_id 即将发生变化的表面层的ID。
w 新表面层的宽度。
h 新的表面层的高度。


返回:

N/A(无返回值)


描述

这个函数将重置表面的大小为给定的长宽值(像素)。这个 surface_id 是之前创建好的表面层,或者是application_suface,这个函数将重置表面层的大小。Note that this will neither crop nor stretch the contents of the surface, but rather it destroys the current surface and recreates it with the same handle (surface_id) with the new dimensions, meaning that it will need to be cleared and drawn to again (unless it is the application_surface in which case GameMaker Studio 2 will do this automatically).

注:如果你重置应用表面层的大小,它不会马上发生改变,直至下一个绘制帧,这意味着在同一个事件或者步事件中使用 surface_get_width() 或者 surface_get_height() 函数将返回之前的值。


例如:

if view_wport[0] != surface_get_width(application_surface) || view_hport[0] != surface_get_height(application_surface)
   {
   surface_resize(application_surface, view_wport[0],view_hport[0]);
   }

上述代码将检测视野输出大小是否与“应用表面”的一致,如果不同,将重置表面层的大小。