There's two ways to transform the image on screen. Either you pass the proper values to the image draw call or you use the graphics transformation calls which apply to everything drawn in between.
For example, say I have an image and I want to draw it at 100, 100. I can do this the normal way:
Code: Select all
love.graphics.draw(image, 100, 100)
Or the transformation way:
Code: Select all
love.graphics.push()
love.graphics.transform(100, 100)
love.graphics.draw(image, 0, 0)
love.graphics.pop()
Why bother with the second version? It does the same thing. Note the image being drawn at 0, 0 because the coordinates system itself has been moved to 100, 100 so the image draws relatively to 100, 100. So if you were to put 100, 100 in the image too it would move to 200, 200. Hope that makes sense for you.
Now, the benefit to the second version is that you can put anything you want in between the push and pop and it'll apply to all those drawables. Text, images, quads, meshes, EVERYTHING that can be drawn.
You can ALSO nest push and pop inside others. For example, say you want to rotate an image around its center? For the example, imagine the image is 100, 100 pixels in size. In the first example you would pass half the width and height as the offset X and Y values for the image as well as the rotation in its rotation argument. But for the second example you'd do it a bit differently...
Code: Select all
love.graphics.push()
love.graphics.transform(50, 50)
love.graphics.rotate(1)
love.graphics.transform(-50, -50)
love.graphics.draw(image, 0, 0)
love.graphics.pop()
What's happening here is first the coordinates system is moved to 50, 50, or half the images size. Then it the imagebefore moving it back to the newly rotated 0, 0 position.
Using this method you can do some neat effects. Like utilize scaling to have it scale or zoom the contents from their center.
Play around. Create a sample project with just an image or two and do some tests and see what you can do. Read up on the Wiki for more.
Couple this with an animation library like Flux and you can do some really awesome stuff..
You can do all this cool stuff (Referring to the inventory and shop UI) with a tweening library and the transformation stack.
(Apologies for once again possibly blowing someone's mind with my work. I'm so sorry.)