Page 1 of 1
Easy q.
Posted: Sun Mar 21, 2010 2:34 pm
by Xoria
How do I execute a function a a particular x and y? Do I put it in the argument, bracket thing at the end of the function? I searched but couldn't find anything.
Re: Easy q.
Posted: Sun Mar 21, 2010 2:53 pm
by Robin
What exactly do you want? What do you mean by 'at a particular x and y'?
Re: Easy q.
Posted: Mon Mar 22, 2010 12:44 pm
by Xoria
If I have a function that draws something, how do I make it at a cirtain x, & y without actually putting it in.
Like love.graphics.draw( drawable, x, y, r, sx, sy, ox, oy )
insead of entering x, and y, can one enter nothing for the x, & y but still make it execute at a particular place?
Like
function drawthing()
love.graphics.draw(drawable)
end
How can I make drawthing occur at a particular x, & y without actually entering it in? Is there another way?
I feel so stupid. -_-
Re: Easy q.
Posted: Mon Mar 22, 2010 12:55 pm
by nevon
Xoria wrote:How can I make drawthing occur at a particular x, & y without actually entering it in? Is there another way?
How would it possibly know where to draw the thing unless you tell it? However, you don't necessarily have to enter numbers literally. You could draw it to coordinates from a variable. For example, if you wanted to draw something at the cursor, you would do:
Code: Select all
function love.draw()
love.graphics.draw(ourimage, love.mouse.getX(), love.mouse.getY())
end
Re: Easy q.
Posted: Mon Mar 22, 2010 1:50 pm
by kikito
Maybe you mean that you want to use default values for x and y?
Code: Select all
function drawthing(drawable, x, y)
x = x or 100
y = y or 200
love.graphics.draw(x,y, drawable)
end
This function will accept x and y as parameters. If you don't pass them, it will assign them 100 and 200.
Code: Select all
drawthing(drawable, 500, 600) -- draws drawable thing on x=500, y=600
drawthing(drawable) -- draws drawable thing on x=100, y=200
Re: Easy q.
Posted: Mon Mar 22, 2010 3:55 pm
by Robin
kikito wrote:Code: Select all
function drawthing(drawable, x, y)
x = x or 100
y = y or 200
love.graphics.draw(x,y, drawable)
end
Fail: it should be love.graphics.draw(drawable, x, y).
@Xoria: do you expect LÖVE to know where you want your image to be drawn, or something else?
Re: Easy q.
Posted: Tue Mar 23, 2010 3:39 pm
by Xoria
Nah, those last 2 posts did it for me. Tnx as usual.