Easy q.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Easy q.

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Easy q.

Post by Robin »

What exactly do you want? What do you mean by 'at a particular x and y'?
Help us help you: attach a .love.
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Re: Easy q.

Post 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. -_-
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: Easy q.

Post 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
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Easy q.

Post 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
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Easy q.

Post 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). :P

@Xoria: do you expect LÖVE to know where you want your image to be drawn, or something else?
Help us help you: attach a .love.
Xoria
Citizen
Posts: 61
Joined: Sun Jan 31, 2010 1:24 am

Re: Easy q.

Post by Xoria »

Nah, those last 2 posts did it for me. Tnx as usual.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests