How can I get the coordinates of an Image?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
tavuntu
Citizen
Posts: 65
Joined: Mon Dec 24, 2012 6:56 am
Contact:

How can I get the coordinates of an Image?

Post 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)
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: How can I get the coordinates of an Image?

Post 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.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
tavuntu
Citizen
Posts: 65
Joined: Mon Dec 24, 2012 6:56 am
Contact:

Re: How can I get the coordinates of an Image?

Post 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 :)
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests