【问题标题】:I've used setDefaultFilter but the text is still too pixelated我使用了 setDefaultFilter 但文本仍然太像素化
【发布时间】:2021-03-30 19:49:58
【问题描述】:
    Class = require 'class'
push = require 'push'

WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720

VIRTUAL_WIDTH = 432
VIRTUAL_HEIGHT = 243


function love.load()

    love.window.setTitle('Maze')


    love.graphics.setDefaultFilter('nearest', 'nearest')

    smallFont = love.graphics.newFont('HARRYP__.TTF', 25)
    
    push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
        fullscreen = false,
        vsync = true,
        resizable = false,
    })
end


function love.draw()
    push:apply('start')

    love.graphics.clear(30 / 255, 30 / 255, 50 / 255, 1)

    love.graphics.setFont(smallFont)
    love.graphics.printf('Hello, world!', 0, VIRTUAL_HEIGHT / 2 - 6, VIRTUAL_WIDTH, 'center')

    push:apply('end')
end

我尝试更改字体大小,但它仍然像素化。但是我看到其他人使用与此类似的代码,并且文本清晰明了。

【问题讨论】:

    标签: text lua love2d


    【解决方案1】:

    这取决于您的字体的详细程度。如果在渲染后不充气,您使用的会更好看。通过此时关闭虚拟游戏场,然后直接在屏幕上绘图,您会看到更好的结果。这对于标题来说更容易做到,因为它更容易定位在一般区域而不是特定位置。

    function love.draw()
        push:apply('start')  --  enable virtual size
        love.graphics.clear(30 /255, 30 /255, 50 /255, 1)
    
        --  draw your game graphics here
    
        push:apply('end')  --  disable virtual size
    
        love.graphics.setFont(smallFont)
        love.graphics.printf('Hello, world!', 0, WINDOW_HEIGHT /2 -6, WINDOW_WIDTH, 'center')
    end
    

    你也可以试试不同的字体大小,看看有没有效果。

    smallFont = love.graphics.newFont('HARRYP__.TTF', 30)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-03-28
      • 2011-11-21
      • 2015-05-08
      • 2023-03-12
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多