必须先调用此函数,然后才能定义任何基元。有6种类型的基元可以定义为以下常量:
常量 | 描述 |
---|---|
pr_pointlist | A point list - A point is drawn for every vertex. |
pr_linelist | A line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc. |
pr_linestrip | A line strip - A line is drawn between the first and the second vertex, between the second and the third vertex, the third and the fourth vertex, etc. |
pr_trianglelist | A triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc. |
pr_trianglestrip | A triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc. |
pr_trianglefan | A triangle fan - Every two vertices connect to the first vertex to make a triangle. WARNING This primitive type is not natively supported on some platforms and there could be a performance hit if you use it. |
下图基本上说明了它们的外观以及定义顶点的顺序:
注意 在某些平台 (Windows、Xbox) 上,pr_trianglefan 类型本身不受支持,因此 GameMaker 在编译游戏时会进行转换以使它们正常运行。这意味着在这些平台上,pr_trianglefan 类型的使用速度将比其他类型慢得多。
警告 除非您在 游戏选项 中启用了 WebGL,否则这些函数无法与 HTML5 模块配合使用。
draw_primitive_begin(kind);
参数 | 类型 | 描述 |
---|---|---|
kind | 基元类型常量 | 你要绘制的基元类型。 |
N/A
var _steps = 20;
var _xx = 50;
var _yy = 50;
var _radius = 30;
draw_primitive_begin(pr_trianglefan);
draw_vertex(_xx, _yy);
for(var i = 0; i <= _steps; ++i;)
{
draw_vertex(_xx + lengthdir_x(_radius, 270 * i / _steps), _yy + lengthdir_y(_radius, 270 * i / _steps));
}
draw_primitive_end();
上述代码将绘制由基元组成的圆的四分之三。