draw_polygon and draw_colored_polygon won't work for me

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Zombieakopaluetze

Hi there,

I was playing with the _draw function and I just can’t get draw_polygon to work and I dont get why. The other methods seem to work with the same set of variables. My scene is a Node2D with this simple script:

extends Node2D
var pts = PoolVector2Array()
var uvs = PoolVector2Array()
var clrarr = PoolColorArray()
var clr = Color(1,1,1,1)
func _draw():
	for i in range(4):
		var myx = floor(rand_range(100,600))
		var myy = floor(rand_range(100,600))
		pts.append(Vector2(myx, myy))
	#draw_polyline(pts,Color(1,0.5,0,1), 1.0, false)
	#draw_polyline_colors(pts,clrarr, 1.0, false)
	#draw_multiline(pts, clr)
	#draw_primitive(pts, clrarr, uvs, null, 3.0, null)
	#won't work
	#draw_colored_polygon(pts, clr, uvs, null, null, false)
	#draw_polygon(pts, clrarr, uvs, null, null, false)

Any advice or hint what’s wrong?

Ok, it kind of works with this line, when I not try to set the uv-PoolVector2Array. I guess this uv-array needs another size than the corresponding points array:

draw_colored_polygon(basepoints, clr, PoolVector2Array(), null, null, true)

But not with the random point positions. Seems like there must be some kind of order to them, so that the borderlines dont intersect or soemethings like that. I’ll try to figure it out.

Zombieakopaluetze | 2018-10-07 11:13