0 votes

Hi,
how can I draw a sprite in the center of a given tile? I tried calculating the center based on the tile size, but the sprite is always a little bit off to the upper-left corner. Note: I scale down the original texture (see below):

var world_pos = _tilemap.map_to_world(Vector2(x,y))
var quest_sprite = Sprite.new()
quest_sprite.set_texture(load("res://scenes/map/textures/quest_mark.png"))
quest_sprite.set_z(100)
print(quest_sprite.get_texture().get_size())
quest_sprite.scale(Vector2(0.1,0.1))
quest_sprite.set_pos(world_pos + _tilemap.get_cell_size() /2 )
add_child(quest_sprite)
in Engine by (64 points)

Please log in or register to answer this question.

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.