i have been trying to use the mouse wheel up to zoom in and mouse wheel down to zoom out of an image..i have been trying to find a code for that and been trying to write one myself but cant do it..anyone can help me plz..
function love.load()
hamster = love.graphics.newImage("world_map.gif")
end
function love.update(dt)
if love.mouse.isDown("wu") then
love.graphics.scale(hamster, 45, 65)
end
end
function love.draw()
love.graphics.print( text, 330, 300 )
love.graphics.draw(hamster, x, y)
if love.mouse.isDown("wu") then
love.graphics.scale(hamster, 45, 65)
end
end
end
thank you in anticipation
regards
image scaling on mouse wheel up/down
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: image scaling on mouse wheel up/down
You are using scale wrong: http://love2d.org/wiki/love.graphics.scale
Code: Select all
function love.load()
image = love.graphics.newImage("body.png")
scale = 1
end
function love.update(dt)
--do nothing
end
function love.draw()
love.graphics.scale(scale,scale)
love.graphics.draw(image,0,0)
end
function love.mousepressed(x,y, button)
if button == "wu" then
scale = scale + scale / 4
elseif button == "wd" then
scale = scale - scale / 4
end
end
- Attachments
-
- scale.love
- 0.7.0
- (3.45 KiB) Downloaded 260 times
Re: image scaling on mouse wheel up/down
This is the way I do it
Code: Select all
function love.mousepressed( x, y, mb )
if mb == "wu" then
scale = scale - 0.2
end
if mb == "wd" then
scale = scale + 0.2
end
end
function love.draw()
love.graphics.scale(scale)
end
Who is online
Users browsing this forum: No registered users and 3 guests