how to change fontsize during the game in XNA?

后端 未结 3 1864
心在旅途
心在旅途 2021-02-20 16:55

I need to use different fontsize of spritefont, Have to I create new spritefont for the each size?

3条回答
  •  囚心锁ツ
    2021-02-20 17:35

    Basically yes.

    There is an overload of SpriteBatch.DrawString that gives you an option to scale your text.

    However the major downside to this is that your text will become pixelated as you scale it up. If you start at a higher resolution and scale down you will start to get artefacts as you get to smaller sizes.

    So if you have a fixed number of sizes, you should create multiple versions of your sprite font at the different sizes you require.

    If you want continuously scalable text with sharp edges, you could perhaps look into vector fonts. The Nuclex Framework has some code to do that.

提交回复
热议问题