0 votes

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.


in Engine by (163 points)

2 Answers

0 votes

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.

by (2,045 points)
0 votes

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)
by (939 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.