Page 1 of 1
How can I get the coordinates of an Image?
Posted: Fri Mar 08, 2013 7:31 pm
by tavuntu
I'm a noob in this engine and I just learned how to use getWidth() and getHeight() from an Image object and I was looking for getX() or something like that in the forum but nothing relevant.
Thanks a lot.
(Sorry for the bad English)
Re: How can I get the coordinates of an Image?
Posted: Fri Mar 08, 2013 8:06 pm
by Taehl
Images don't have coordinates. They appear wherever you love.graphics.draw them, where you specify the coordinates yourself. So you already have the coordinates.
Conventionally, games tend to use a table for each character, so say player={}. Then we set player.x=30 and player.y=50, for instance. And in love.draw, we use player.x and player.y for the draw coordinates. That way, you can check player.x and player.y whenever you want.
Re: How can I get the coordinates of an Image?
Posted: Fri Mar 08, 2013 9:05 pm
by tavuntu
Taehl wrote:Images don't have coordinates. They appear wherever you love.graphics.draw them, where you specify the coordinates yourself. So you already have the coordinates.
Conventionally, games tend to use a table for each character, so say player={}. Then we set player.x=30 and player.y=50, for instance. And in love.draw, we use player.x and player.y for the draw coordinates. That way, you can check player.x and player.y whenever you want.
I see, thanks Taehl