This is under love.mousepressed(x,y)
so if I have..
Code: Select all
if x > v.x and
x < v.x + medium:getWidth(v.text) and
y > v.y and
y < v.y + medium:getHeight() then
click the button
end
Code: Select all
if x > v.x and
x < v.x + medium:getWidth(v.text) and
y > v.y and
y < v.y + medium:getHeight() then
click the button
end
This might work..baconhawka7x wrote:I have my camera zoomed by 0.3. And I have a GUI system, where I want to test if the player is clicking on 'v.text'.
This is under love.mousepressed(x,y)
so if I have..So, how would I change that so that it works with the camera zoom? (camera.scaleX,camera.scaleY).Code: Select all
if x > v.x and x < v.x + medium:getWidth(v.text) and y > v.y and y < v.y + medium:getHeight() then click the button end
Code: Select all
if x > v.x and
x < v.x + (medium:getWidth(v.text) * camera.scaleX) and
y > v.y and
y < v.y + (medium:getHeight() * camera.scaleY) then
click the button
end
Can I get a link?dreadkillz wrote:You can take a look at my vrld's hump.camera or my camera mod for how to convert coordinates.
Yesbaconhawka7x wrote:Can I get a link?dreadkillz wrote:You can take a look at my vrld's hump.camera or my camera mod for how to convert coordinates.
Code: Select all
function camera:cameraCoords(x,y)
local w,h = love.graphics.getWidth(), love.graphics.getHeight()
x,y = vec.rotate(self.rot, x-self.x, y-self.y)
return x*self.zoom + w/2, y*self.zoom + h/2
end
function camera:worldCoords(x,y)
local w,h = love.graphics.getWidth(), love.graphics.getHeight()
x,y = vec.rotate(-self.rot, vec.div(self.zoom, x-w/2, y-h/2))
return x+self.x, y+self.y
Users browsing this forum: Bing [Bot] and 3 guests