Libgdx glyphLayout中的targetWidth是什么

Libgdx glyphLayout中的targetWidth是什么,libgdx,bitmap-fonts,Libgdx,Bitmap Fonts,参数targetWidth在这里的确切含义是什么?它与wrap参数有什么关系 public GlyphLayout (BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap) { setText(font, str, color, targetWidth, halign, wrap); } 从文件: targetWidth:用于对齐、换行和截断的宽度。如果未使

参数
targetWidth
在这里的确切含义是什么?它与
wrap
参数有什么关系

public GlyphLayout (BitmapFont font, CharSequence str, Color color, float targetWidth, int halign, boolean wrap) {
    setText(font, str, color, targetWidth, halign, wrap);
}
从文件:

targetWidth:用于对齐、换行和截断的宽度。如果未使用这些功能,则可能为零

换行:如果为真,则(一个单词或一个文本单位)将在达到页边空白时自动转入新行,或与嵌入的特征相适应

如果为false,文本将仅在包含换行符的位置换行(\n)

编辑 测试代码:实际演示,targetWidthwrap如何在
GlyphLayout
构造函数中工作

公共类MyGdxGame扩展应用程序适配器{
专用字形布局字形布局[];
私有位图字体位图字体;
专用浮点数targetWidth=250;
私人shaperender shaperender;
私人SpriteBatch SpriteBatch;
私人浮动XPO[]={450450,30450880};
私人浮动YPO[]={550480410340340};
@凌驾
公共void创建(){
spriteBatch=新spriteBatch();
ShaperEnder=新的ShaperEnder();
shaperender.setAutoShapeType(真);
bitmapFont=新的bitmapFont(Gdx.files.internal(“skin/poter.fnt”);
glyphLayout=新glyphLayout[6];
glyphLayout[0]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.left,false);
glyphLayout[1]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.right,false);
glyphLayout[2]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.center,false);
glyphLayout[3]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.left,true);
glyphLayout[4]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.right,true);
glyphLayout[5]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.center,true);
}
@凌驾
公共无效呈现(){
Gdx.gl.glClearColor(1f、0f、0f、1f);
Gdx.gl.glClear(GL20.gl\u颜色\u缓冲\u位);
spriteBatch.begin();
对于(int i=0;i来自文件:

targetWidth:用于对齐、换行和截断的宽度。如果未使用这些功能,则可能为零

换行:如果为真,则(一个单词或一个文本单位)将在达到页边空白时自动转入新行,或与嵌入的特征相适应

如果为false,文本将仅在包含换行符的位置换行(\n)

编辑 测试代码:实际演示,targetWidthwrap如何在
GlyphLayout
构造函数中工作

公共类MyGdxGame扩展应用程序适配器{
专用字形布局字形布局[];
私有位图字体位图字体;
专用浮点数targetWidth=250;
私人shaperender shaperender;
私人SpriteBatch SpriteBatch;
私人浮动XPO[]={450450,30450880};
私人浮动YPO[]={550480410340340};
@凌驾
公共void创建(){
spriteBatch=新spriteBatch();
ShaperEnder=新的ShaperEnder();
shaperender.setAutoShapeType(真);
bitmapFont=新的bitmapFont(Gdx.files.internal(“skin/poter.fnt”);
glyphLayout=新glyphLayout[6];
glyphLayout[0]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.left,false);
glyphLayout[1]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.right,false);
glyphLayout[2]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.center,false);
glyphLayout[3]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.left,true);
glyphLayout[4]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.right,true);
glyphLayout[5]=新的glyphLayout(位图字体,“加载屏幕”,Color.BLACK,targetWidth,Align.center,true);
}
@凌驾
公共无效呈现(){
Gdx.gl.glClearColor(1f、0f、0f、1f);
Gdx.gl.glClear(GL20.gl\u颜色\u缓冲\u位);
spriteBatch.begin();

for(int i=0;iTarget width是文本在包装、截断或以其他方式更改为单行之前的最大宽度


例如考虑一个宽度为500的字符串(绘制时)。目标宽度为250时,它将被包裹在250行中(2行)(如果包是真的)。


例如考虑一个宽度为500的字符串(绘制时)。目标宽度为250时,它将被包裹在250到2行(如果包是真的)。;当我将目标宽度从1增加到2时,什么也没有发生,但从1增加到3,整个文本变成垂直的……那么目标宽度的增加或减少与包裹参数有什么关系呢。@ShubhamTripathi请检查我的更新答案,以获得实际的图形解释。如果我将目标宽度从250增加到255,结果仍然是一样的,为什么…?以及感谢您所做的努力。这取决于(许多情况),如果您选择“左对齐”和“展开”,则结果将在targetwidth的所有变化中始终保持不变。如果文本宽度为l