Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Drawsi |
I just can’t seem to find a way to make it work well, it doesn’t work all the way on the far left.
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Drawsi |
I just can’t seem to find a way to make it work well, it doesn’t work all the way on the far left.
Reply From: | deaton64 |
Hi,
When you say it doesn’t work on the far left, do you mean it’s not putting the sprite in the centre of the grid box or something else?
If it’s the first part of the above, and you know the coords of grid square… ie x = 10, y = 2, the do something like Vector2( (x * 64) - 32, (y * 64 - 32) )
- assuming that your grid starts at 1,1. That should put you in the middle of the grid square.
Reply From: | juppi |
Try this:
func _draw():
for x in range(1, grid_size.x, cell_size):
for y in range(1, grid_size.y, cell_size):
draw_rect(Rect2(x, y, cell_size, cell_size), Color.green, false, 1.0, false)