问题标签 [libgdx]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1738 浏览

java - 如何避免 libgdx SpriteBatch/BitmapFont 破坏 Texture.bind?

...这是一些绘制一些文本的代码:

代码的第一位工作,一帧又一帧,直到第二位代码运行。之后,仅使用最新的 glMaterial 渲染第一位的三角形带。知道为什么会这样吗?我应该怎么做才能使两种材料都保持在绘图中(网格的“纹理”及其精灵纹理,应该不同)?

0 投票
1 回答
425 浏览

box2d - PolygonShape 内的 box2d PolygonShape

我创建了包含框的全屏“边框”(框应在此边框框内移动)。Boxes 是动态的,而borderBox 是静态的。BorderBox 是 PolygonShape,盒子也是 PolygonShape。

但是当我在borderBox内“放置”框时,它会自动移出borderBox。

我该怎么办?我可以使用 PolygonShape 来创建这样的边框,还是应该只画线而不是画线?

0 投票
1 回答
631 浏览

java - Libgdx - 如何清洁颜色?

我正在尝试绘制一些图像。我正在使用精灵和setColor,但是,当我尝试将图像绘制为白色时,它不起作用。它保持最后的颜色。我也尝试使用Color.CLEAR,后来涂成白色,但它不起作用。那么,我该怎么做呢?

0 投票
2 回答
1405 浏览

box2d - 如何生成适合形状的纹理?

我有一系列随机生成的 EdgeShapes,如下所示:

在此处输入图像描述

我的问题是,如何用纹理填充底部区域以使其看起来像地面?

0 投票
1 回答
1124 浏览

java - Box2D - 如何防止在靠近墙壁时连续跳跃

问候stackoverflow社区!

我正在开发一款使用 Box2D 进行碰撞检测和物理的 Android 游戏。现在,我正在实现一个基本的平台游戏系统。跳跃是到位的,但它有一个小故障。以下函数用于确定玩家是否在地面上。很简单,对吧?好吧,它可以正常工作,除非玩家就在墙旁边,在这种情况下,它只会让他不断地跳起来,因为该函数仍然会返回 true,即使墙不在玩家的正下方。

我尝试添加额外的 x-checks 以确保我与直接在我下方的东西发生碰撞,但无济于事。

那么,是否有人对我可以做些什么来提高 isGrounded 检查的效率有任何指示?

提前致谢!:)

0 投票
1 回答
4445 浏览

java - 是否可以在 Libgdx 中编写 C/C++ 代码?

您如何使用适用于 Android 和桌面的 Libgdx 编写本机 (C/C++) 代码?谢谢。

0 投票
4 回答
8068 浏览

java - 绘制在 libgdx 中旋转的 BitmapFont

我似乎无法弄清楚如何正确旋转位图字体。我认为您修改了 SpriteBatch 的转换矩阵。但是,尝试旋转会使文本围绕某个点旋转,我不知道如何相对于文本本身旋转它。

0 投票
7 回答
14945 浏览

android - Cocos2D 或 libgdx 用于 Android 游戏开发

我只是想知道,从长远来看,使用这些引擎中的哪一个会更好。虽然我觉得使用 Cocos2D 会是更好的选择,因为它也可以用于 iphone 开发,但只有 1 个教程http://dan.clarke.name/2011/04/how-to-make-a-simple- android-game-with-cocos2d/到目前为止我已经找到了。另一方面,libgdx 有一本完整的书。

0 投票
1 回答
1850 浏览

android - 将 OpenGL Android 更改为 LibGDX OpenGL

我有一个具有原生 android OpenGL 实现的项目。MyView 扩展了 GLSurfaceView,而 MyRenderer 实现了 GLSurfaceView.Renderer。我对实施不满意,因为它匆忙完成并且不合适。我想将其更改为 LibGDX 实现。几个问题,值得吗?我没有为现有的 opengl 实现使用任何本机代码,我对 C/C++ 代码并不熟悉。因此,通过切换到 LibGDX,我会看到性能提升。其次,做起来有多难。我刚开始使用 LibGDX,让应用程序在我的设备上运行。我最好在 NDK 或 LibGDX 上投入时间吗?

0 投票
3 回答
3741 浏览

android - Kindle Fire changes Screen Resolution at some point…

Disclaimer: this is a strange issue that only happens in a Kindle Fire (so far).

Technologies Involved: Android SDK, Eclipse, LibGDX.

I have a relatively simple app running with LibGDX. The way LibGDX works is by having an OpenGL thread that will call Create() (once) and then Render() as many times as possible (so you can do your render…).

So when you initialize the Device, your "Create()" method is called and then when the OpenGL surface is initialized (all this happens automagically), your Render() starts getting called.

If the OpenGL context is lost, destroyed, etc. your Resize(width,height) method is called by LibGDX.

So far. So good.

Now I came across a strange issue with a Kindle Fire where things looked a few pixels off or "cut". The Kindle Fire has a "softbar" at the bottom of the screen (20 pixels) that you can't hide or skip, which is "kind of ok" because the device doesn't have physical buttons. You're expected to touch this soft bar and get a bigger bar to go back, go home, etc. According to Amazon, this bar cannot be removed. (is not 100% clear but nobody has found a way -that is not breaking the Amazon rules). The only App I've seen that removes that is the Amazon Video Players for videos streamed from Amazon's Cloud only. So as you can see, there doesn't seem to be a way to "permanently" hide that bar.

So if the bar is there, your real screen state is not the hardware resolution 1024x600 (landscape) but 1024x580. So I added some logging to my methods to see what was going on, and was surprised with this… (remember the create(), render() and resize() methods):

So the screen has been "resized" by the Kindle Fire, "at some point".

Has anyone come across something like this?

This is a screenshot (notice the black bar on top, that's not added by me!). Forgive me for blurring the image but this is a client's project and I can't "disclose" anything.

enter image description here

The fun part begins when sometimes, the bar won't be there and the app will look like the next (again, sry for the blur). Notice how the top bar is not there…</p>

enter image description here

Upon a closer examination of both shots, you can tell that the bottom (which should be the same), is not. The kindle is doing strange things.

Any ideas?

The assets were originally packed as 1024x600 but we have changed that (580 now) and will assume that the viewport is now 1024x580 but I was wondering if anyone found a better way to deal with this nonsense? :)

note: we do have android:theme="@android:style/Theme.NoTitleBar.Fullscreen" in the manifest. Doesn't do anything.

Thanks in advance.