“拆分(regEx)”和“拆分(regEx,0)”之间的Java区别?(Java difference between “split(regEx)” and “split(regEx, 0)”?)
使用
split(regEx)
和split(regEx, 0)
之间有什么区别吗?因为输出是针对我测试的情况相同。 例如:
String myS = this is stack overflow; String[] mySA = myS.split(' ');
导致
mySA === {'this','is','stack,'overflow'}
和
String myS = this is stack overflow; String[] mySA = myS.split(' ', 0);
也导致
mySA === {'this','is','stack,'overflow'}
这里有“隐藏”的东西吗? 还是需要了解
.split(regEx, 0)
?Is there any difference between using
split(regEx)
andsplit(regEx, 0)
?Because the output is for the cases I tested the same. Ex:
String myS = this is stack overflow; String[] mySA = myS.split(' ');
results in
mySA === {'this','is','stack,'overflow'}
And
String myS = this is stack overflow; String[] mySA = myS.split(' ', 0);
also results in
mySA === {'this','is','stack,'overflow'}
Is there something "hidden" going on here? Or something else which needs to be known about the
.split(regEx, 0)
?
原文:https://stackoverflow.com/questions/29603365
最满意答案
执行此操作的最佳方法是使用仅具有白色像素(可以改变alphas)的纹理,并在使用
SpriteBatch.setColor(r,g,b,a)
绘制它们之前对其进行着色 - 之后设置回Color.WHITE
。除了必须暂停逐个像素地转换纹理之外,最大的优点是纹理不需要在自己的文件中设置,但可以与所有其他纹理放在相同的TextureAtlas中没有着色的。 因为没有必要绑定纹理的不同颜色版本,
SpriteBatch
最终会减少渲染调用,这意味着渲染速度更快。The best way to do this is to use textures with only white pixels (which varying alphas), and tinting them before drawing them with
SpriteBatch.setColor(r,g,b,a)
--just set back toColor.WHITE
after.Aside from having to pause to transform the texture pixel-by-pixel, the biggest advantage of this is that the texture doesn't need to be set in its own file, but can be put in the same TextureAtlas as all of the other textures that aren't being tinted. Because it's not necessary to bind different colored versions of the texture,
SpriteBatch
ends up making a lot fewer rendering calls, which means faster rendering.
相关问答
更多-
在libGDX中的TrueType字体(TrueType Fonts in libGDX)[2022-08-31]
是的,您一定需要将gdx-stb-truetype jar添加到您的项目中,正如您在编辑中所述。 这里是你将如何使用它,非常直观... 首先你需要声明你的BitmapFont和你将使用的字符...... BitmapFont font; public static final String FONT_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][_!$%#@|\\/?-+=()*&.;,{}\"´` ... -
控制Libgdx中的广告(Controlling Ads in Libgdx)[2022-01-28]
它可能会说,因为隐藏广告并不能阻止以前从服务器获取广告。 因此,当您隐藏广告时,它仍然算作印象但不会带来金钱并降低平均赚钱(RPM)。 但现在,当您隐藏广告时,它不再提取广告,因此现在不用担心。 It probably says that because hiding ads wasn't stop the fetching ads from server formerly. So when you hide ads it was still counting as impression but not b ... -
android中的libgdx(libgdx in android)[2023-06-14]
您是否在扩展AndroidApplication的Android类中初始化它? 它应该看起来像: public void onCreate(final Bundle savedInstanceState) { super.onCreate( savedInstanceState ); this.initialize(new Game2D, false); } 参数“false”告诉应用程序使用OpenGL ES 1.0(GL10): OpenGL ES 1.0 == GL10 OpenGL ... -
拉伸libgdx中的按钮?(Stretching buttons in libgdx?)[2020-12-01]
你在寻找什么称为NinePatch 。 基本上,这是一种特殊的图像,它定义了图像的可拉伸和不可拉伸的部分。 NinePatch的典型用例是Button,因为您通常不希望边缘被拉伸而只是拉伸其余部分。 实例化的一个简单示例是: NinePatch patch = new NinePatch(new Texture(Gdx.files.internal("knob.png")), 12, 12, 12, 12); 有关此示例的更多详细信息,请参阅有关NinePatches的Wiki页面: https : / ... -
在libgdx中动画(Animation in libgdx)[2023-10-22]
如果纹理布局在网格中,您可以使用TextureRegion#split(texture,tileWidth,tileHeight)获取纹理的一堆纹理区域。 您也可以使用一组松散图像上的TexturePacker将它们打包成单个纹理,然后使用TextureAtlas加载。 这有一个好处,它可以从每个框架中去除空白以获得更好的打包效果,并且也可以做别致的东西(如果两个框架是相同的,它只会打包一次)。 将您的框架图像命名为anim_1.png,anim_2.png等,然后根据框架编号将所有名为“anim”的纹理区 ... -
执行此操作的最佳方法是使用仅具有白色像素(可以改变alphas)的纹理,并在使用SpriteBatch.setColor(r,g,b,a)绘制它们之前对其进行着色 - 之后设置回Color.WHITE 。 除了必须暂停逐个像素地转换纹理之外,最大的优点是纹理不需要在自己的文件中设置,但可以与所有其他纹理放在相同的TextureAtlas中没有着色的。 因为没有必要绑定纹理的不同颜色版本, SpriteBatch最终会减少渲染调用,这意味着渲染速度更快。 The best way to do this is ...
-
此问题已得到解决。 Libgdx库存在一些错误,这些错误会导致合并不同模型的许多问题(同时模型可以合并而没有任何问题)。 我找到了解决这个问题的合适方法,它让我无法正确使用VBO系统。 有关更多信息,请参阅以下链接: libGDX中的慢模型批处理渲染 http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=10842 This issue has been solved. Libgdx library has some bugs which cause ...
-
列表视图在Libgdx中(List View In Libgdx)[2022-09-13]
如果你想使用原生的android listview,你应该参考这个 但在大多数情况下,改变活动可能不是一个好主意。 因此,scene2d中的List类将是一个很好的选择。 您可以使用项目数组对其进行初始化,并使用选择更改侦听器来执行加电选择。 有关更多信息,请参阅此 I came accross with the alternative solution. implements gestureListener provided by Libgdx and used pan method. -
LibGDX shapeRenderer(LibGDX shapeRenderer)[2022-07-02]
如果您正在使用scene2d,则不一定需要使用ShapeRenderer渲染某些形状。 scene2d为您提供了一个调试模式,例如在actor周围绘制设置的边界框。 这发生在drawDebug() 当然,您可以覆盖此方法以添加其他形状(将在其中使用ShapeRenderer )。 例如,如果您有一名演员代表一个球,您可能需要围绕演员的边界绘制一个圆以在调试模式下查看可点击区域。 当然,您还应该相应地覆盖collides()方法以进行正确的碰撞检测。 如果您打算在游戏中的不同角色之间进行碰撞检测,请考虑使用b ... -
在LibGdx中处理屏幕(Disposing Screens in LibGdx)[2021-09-03]
您不需要在Libgdx中部署Screen对象。 Screen对象不会将任何资源加载到内存中,它只是ApplicationAdapter用于委派工作的逻辑类。 查看此内存管理维基部分,它们提供了需要手动处理的类列表。 You do not need to dispose Screen objects in Libgdx. Screen objects do not load any resources into memory, it is merely a Logical class that Applica ...