hi, so i am a beginner here, and i have some problems with mouse position,
so, let say i am trying to do this:
love.draw()
love.graphics.print(love.mouse.getX)
end
well, it wont work.. ive see the documentation and i think i dont really understand, can anyone explain about it ? i am trying to get the mouse position so i can make an object position same with the mouse position
mouse position problem
Re: mouse position problem
Try this
love.mouse.getX is a function, You need to end it with ().
Code: Select all
love.graphics.print(love.mouse.getX())
Re: mouse position problem
oh ok, i tried it using a variable likeveethree wrote: ↑Mon Apr 24, 2017 5:42 am Try thislove.mouse.getX is a function, You need to end it with ().Code: Select all
love.graphics.print(love.mouse.getX())
mousepos = love.mouse.getX()
and print the mousepos.. it works, but the number wont change when i move the mouse...
-
- OnACoffeeBreak
- Prole
- Posts: 28
- Joined: Tue Apr 11, 2017 11:19 am
Re: mouse position problem
Try this as your whole main.lua program. Printed values will update when the mouse cursor is inside the game window:but the number wont change when i move the mouse
Code: Select all
function love.draw()
mousepos_x = love.mouse.getX()
mousepos_y = love.mouse.getY()
love.graphics.print(mousepos_x .. ", " .. mousepos_y, 100, 100)
end
Re: mouse position problem
You're probably calling "mousepos = love.mouse.getX()" in love.load or outside a function. For it to update you need to put it inside love.update or love.draw. Those are called once every frame.PGUp wrote: ↑Mon Apr 24, 2017 11:03 amoh ok, i tried it using a variable likeveethree wrote: ↑Mon Apr 24, 2017 5:42 am Try thislove.mouse.getX is a function, You need to end it with ().Code: Select all
love.graphics.print(love.mouse.getX())
mousepos = love.mouse.getX()
and print the mousepos.. it works, but the number wont change when i move the mouse...
Who is online
Users browsing this forum: No registered users and 3 guests