Just wanted to share a lib of mine which I use in my project to use the x & y coordinates as the upper left point of the image (as it should be). Shouldn't be needed in Löve 0.6 but until then have fun using it.
Usage:
Code: Select all
function load()
love.graphics.setMode( 640, 480, false, true, 0 )
--Include the lib in your project
require("lImage.lua");
--Create a new lImage
myImage = lImage:new ( "circle.png", 200, 200 )
end
function draw()
--Draw the image
myImage:draw()
end
Functions:
Code: Select all
new( image_url) Create a new lImage
new( image_url, x, y ) Create a new lImage and set the x & y coordinates
new( image_url, x, y, angle) Create a new lImage with coordinates x & y and angle in degrees
getX() Returns the images x coordinate
getY() Returns the images y coordinate
getPos() Returns both x & y
getCenter() Returns the x & y coordinates of the images center
getHeight() Returns the images height
getWidth() Returns the images width
getAngle() Returns the angle in degrees (default = 0)
getScale() Returns the scale (default = nil)
getScaleX() Returns the scale x-axis coordinate (default = nil)
getScaleY() Returns the scale y-axis coordinate (defaule = nil)
setX( x ) Set the images x coordinate
setY( y ) Set the images y coordinate
setPos( x, y ) Set both coordinates at the same time
setAngle( angle ) Set the angle
setCenter( x, y) Set the x & y coordinates of the images center
setScale( scale ) Set the scale
setScaleX( sx ) Set the scale x-axis coordinate
setScaleY( sy ) Set the scale y-axis coordinate
draw() Draw the image to the screen with the settings applied
- The x & y coordinates represent the upper left point of the image
- If the angle is not NIL it will be drawn with the angle
- If the scale is not NIL it will be drawn scaled
- If the scale_x & scale_y are not NIL it will be drawn scaled
draw( x ,y ) Same as draw() with manual set x & y coordinates which will be saved
draw( x, y, angle ) Same as draw( x, y) with manual set angle which will also be saved
drawc() Same as draw() except it uses the x & y coordinates as center (default in Löve 0.5)
drawc( x, y ) Same as drawc() with manual set x & y coordinates which will be saved
drawc( x, y, angle ) Same as drawc( x, y ) with manual set angle which will also be saved
Code: Select all
lImage v2.1
* Added "setAngle( angle )"
* Added download in compiled bytecode to save you some time
* Fixed "getAngle()", it wasn't there. Just forgot it somehow..
lImage v2
* Added "draw( x ,y )"
* Added "draw( x, y, angle )"
* Added "drawc( x, y )"
* Added "drawc( x, y, angle)"
lImage v1
* Initial release
License
Code: Select all
THE POETIC LICENSE — Alexander Genaud
© 2009 Gerrit Guenther
This work ‘as-is’ we provide.
No warranty express or implied.
We’ve done our best,
to debug and test.
Liability for damages denied.
Permission is granted hereby,
to copy, share, and modify.
Use as is fit,
free or for profit.
These rights, on this notice, rely.
http://genaud.net/2005/10/poetic-license/
PS: Updated to v2.1!