之前使用AGK开发游戏时苦于只能输出英文,作为中国人很不爽。
经过我的研究,发现是可以输出中文的。
对于Text和Print都适用,一起来看看吧!
- 使用LoadFont加载字体。
- 使用CreateText创建Text。
- 给Text设置大小位置等属性。
- 使用SetTextFont给Text设置字体即可。(或者使用SetPrintFont设置打印的字体)
注意在项目的路径中必须有你的字体。
没有字体也没关系,在下面路径找到系统字体,复制到你的项目文件夹即可。(这些字体必须支持中文才可输出中文)
项目完整代码:
// Project: MyFont
// Created: 2020-04-14
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "字体" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
LoadFont(1,"simfang.ttf")
SetPrintFont(1)
SetPrintSize(60)
CreateText(1,"再见!bye!")
SetTextFont(1,1)
SetTextSize(1,50)
SetTextPosition(1,100,350)
do
Print("仿宋")
Print("如果有帮到您,感谢点个赞!")
Sync()
loop
效果如下: