I would like to draw circles to coordinates using them as middle points of the circles. batch.draw() put circles only “near” coordinates.
What kind of method are you using to draw the circles?
I have added image as a new Sprite.
You need to give us more details, short questions are only going to get short answers, no offence. You need to say what library are you using, how you are tackling the problem, what the problem actually is, and also, if applicable you can show some screenshots showing the problem.
From your question, I found nothing in the above list, your question is unclear, and you didn’t specify what library/engine you are using. What are you trying to achieve? And what is the problem?
So, a png, a circle is defined as a Sprite.
I draw it with batch.draw(), but this function is not uses the given coordinates as middle for the texture. So it doesn’t put the sprite to right place. It should be draw exactly to end of lines.
I guess, you are using Libgdx right?
Anyway, usualy the coordinate you give a “draw()” method are the lower left or upper left of the Texture.
In your case it seems to be the lower left of the Texture.
So in order to draw at the right place, you need to use some offset, which is (-Texture.width/2, -Texture.heigth/2).
This “pushes” the Texture down and left by half of its width and heigth, so that the center is at the position, where the lower, left corner was originally.
Yeah, this should do the trick for you.
Yes, I am using libgdx. I tried to use this so, but is not working:
batch.draw(circle, p.x, p.y, 30, 30, -25, -25);
[quote]The method draw(Texture, float, float, int, int, int, int) in the type SpriteBatch is not applicable for the arguments (Sprite, int,
int, int, int, int, int)
Cast p.x and p.y to a float.
That won’t fix it, since
ints are implicitly cast to
That Batch method expects a Texture, but a Sprite is a TextureRegion. Try one of the Batch methods that takes a TextureRegion.
Centre of a square object is width/2 height /2 , so to draw at the centre of the picture you would do draw(x - (width/2),y -(height.2));