Hi guys,
New Love type person here and I'm trying to figure all this out as best I can, but I've run into a problem. I searched the forums and haven't found this specific problem so thanks in advance.
I'm trying to get an image to scale larger over time as a mouse button is pressed down. As it stands the image only scales at a fixed amount once on a press, but when I use key presses it keeps getting bigger like I want.
function love.update(dt)
x, y = 400 , 300
if love.keyboard.isDown("up") then
sy = sy + 10 * dt -- this works
sx = sx + 10 * dt -- this works too
end
if love.keyboard.isDown("down") then
sy = sy - 10 * dt -- this works too
sx = sx - 10 * dt -- this works too
end
function love.mousepressed(x, y, button)
if button == 'l' then
sx = sx * 100 * dt -- not working like I want
sy = sy * 100 * dt -- not working like I want
end
end
I'm sure this is a pretty nub question, but its driving me nuts. Thanks again.
function love.update(dt)
x, y = 400 , 300
if love.keyboard.isDown("up") then
sy = sy + 10 * dt -- this would increment scale by 10 per second
sx = sx + 10 * dt -- this would increment scale by 10 per second
end
if love.keyboard.isDown("down") then
sy = sy - 10 * dt -- this would increment scale by 10 per second
sx = sx - 10 * dt -- this would increment scale by 10 per second
end
if love.mouse.isDown("l") then
text = "Mouse button right is pressed"
sx = sx + 10 * dt -- gets bigger over time now
sy = sy + 10 * dt -- gets bigger over time now
end
end
The main issue is that you define the love.mousepressed callback inside the love.update callback.
Care to explain why? What I've seen from other examples shows the the love.mousepressed inside the update function. Doesn't this make sure that the key press is checked every second?
Freonce wrote:Care to explain why? What I've seen from other examples shows the the love.mousepressed inside the update function. Doesn't this make sure that the key press is checked every second?
Which examples? We need to know which ones propagate these horrible lies so we can extinguish them. EXTINGUISH!
Which examples? We need to know which ones propagate these horrible lies so we can extinguish them.
I was working off of the Hamsterball tutorial. I think it's right and its working now so no help is needed with this problem anymore thanks. I've actually moved on to the physics stuff and am trying to piece together a little test game.