首页 > 解决方案 > Lua / Love 2d:用像素缩放图像

问题描述

你好 !

使用 Lua 和 Love 2d,我想用像素调整图像的大小:

img = love.graphics.newImage("assets/bg.png")

-- resize the image (500 x 400)

function love.draw()

    love.graphics.draw(bg, 0, 0)

end

标签: imageluaresizescalelove2d

解决方案


我的理解是,您想要以像素艺术风格缩放图像并且您不想要这种模糊效果,您可以在使用 love.graphics.newImage(path) 加载图像之前将默认过滤器设置为最近:

love.graphics.setDefaultFilter("nearest", "nearest")
love.graphics.newImage(path)
love.graphics.setDefaultFilter("linear", "linear") --[[ If you want to let the filter like before ]]

我建议您访问 love2d 论坛。如果这不起作用,请访问此论坛


推荐阅读