我努力学习LibGDX,我安装列出的所有软件在这里上一个新格式化的Mac OS X小牛用一个新的Eclipse 4.3.
一切顺利,重新启动后,我下载并执行gdx-setup.jar,填写表单,然后导入Eclipse.
当我尝试运行桌面时没有错误,没有警告.(右键单击桌面项目,Run As - > Java Application).
我收到了这个错误
Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: badlogic.jpg
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:140)
at com.badlogic.gdx.graphics.glutils.FileTextureData.prepare(FileTextureData.java:64)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:130)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:121)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:100)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:92)
at com.diesel.bugs.DieselBugs.create(DieselBugs.java:21)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
Caused by: com.badlogic.gdx.utils.GdxRuntimeException: File not found: badlogic.jpg (Local)
at com.badlogic.gdx.files.FileHandle.read(FileHandle.java:134)
at com.badlogic.gdx.files.FileHandle.readBytes(FileHandle.java:218)
at com.badlogic.gdx.graphics.Pixmap.<init>(Pixmap.java:137)
Run Code Online (Sandbox Code Playgroud)
我在这里发现了很多类似的问题,我尝试了所有这些都没有任何好结果......昨晚我发现了这个,非常酷我有最新的Java 1.8,一个mac,而Eclipse非常适合......
但是没有成功,我尝试使用Java 1.6和1.7,总是出现同样的错误(找不到文件,我保留了Java 1.7)
我开始做一些调试,这里是我对输入生成的原始代码的唯一修改.
package com.diesel.bugs;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class DieselBugs extends …
Run Code Online (Sandbox Code Playgroud) 我已经使用libGDX实现了一些屏幕,这显然会使用Screen
libGDX框架提供的类.但是,这些屏幕的实现仅适用于预定义的屏幕尺寸.例如,如果精灵用于640 x 480大小的屏幕(4:3宽高比),它将无法按预期在其他屏幕尺寸上工作,因为精灵与屏幕边界相同并且不会缩放到屏幕尺寸一点都不 此外,如果libGDX提供了简单的缩放,我面临的问题仍然存在,因为这会导致游戏画面的宽高比发生变化.
在对互联网进行研究之后,我遇到了一个讨论同一问题的博客/论坛.我已经实现了它,到目前为止它工作正常.但我想确认这是否是实现这一目标的最佳选择,还是有更好的选择.下面是代码,以显示我如何处理这个合法的问题.
论坛链接:http://www.java-gaming.org/index.php? topic = 25685.new
public class SplashScreen implements Screen {
// Aspect Ratio maintenance
private static final int VIRTUAL_WIDTH = 640;
private static final int VIRTUAL_HEIGHT = 480;
private static final float ASPECT_RATIO = (float) VIRTUAL_WIDTH / (float) VIRTUAL_HEIGHT;
private Camera camera;
private Rectangle viewport;
// ------end------
MainGame TempMainGame;
public Texture splashScreen;
public TextureRegion splashScreenRegion;
public SpriteBatch splashScreenSprite;
public SplashScreen(MainGame maingame) {
TempMainGame = maingame;
}
@Override
public …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在IntelliJ Idea中为我的libGDX项目添加Google Play服务.我已按照此处的设置指南进行操作:https://developers.google.com/android/guides/setup
这看起来非常简单.我刚刚在相应的部分中将这些行添加到我的build.gradle中,所以现在看起来像:
project(":android") {
apply plugin: "android"
apply plugin: 'com.android.application'
configurations { natives }
dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
compile 'com.google.android.gms:play-services:11.2.0'
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试在Idea中同步我的gradle项目,以获得"无法解决"错误.
好吧,设置指南还说"确保每次更新Google Play服务时都更新此版本号",但问题是找到该版本号几乎是不可能的:根据Android SDK我的Google Play Services SDK版本manager是"43",到目前为止,我无法将这样的"11.2.0"或任何典型的版本字符串与"43"版本号相关联.并非设置指南对此没有任何说明.
无论如何,我从与此相关的众多问题中尝试了很多事情但无济于事.具体来说,我必须指出我确实更新了我的Android SDK,我确信它是Idea正在使用的那个(我已经三次检查了这个......):
我正在使用API级别26,但无论如何其他定义确实使用Android SDK的相同目录.此外,我没有在这台笔记本电脑上安装任何其他Android SDK,所以毫无疑问,Idea只使用那个和那个.
任何想法都非常受欢迎.
提前致谢!
LibGDX有一个坐标系,其中(0,0)位于左下角.(如下图所示:http://i.stack.imgur.com/jVrJ0.png)
这让我头撞墙,主要是因为我正在移植一个我用普通坐标系统制作的游戏(其中0,0位于左上角).
我的问题:有没有简单的方法来改变这个坐标系?
是否可以使用可导入Xcode的libgdx(RoboVM)创建iOS库或框架?
背景:我的一位同事创建了一个3D可视化应用程序,作为android和windows桌面的libgdx项目.它可以编译为使用RoboVM在iOS上运行.但是,我想使用Xcode在其周围包装额外的本机用户界面元素.我知道可以通过RoboVM以编程方式构建用户界面,但我很想调查是否有可能将现有工作带入Xcode.我不需要编辑3D可视化组件,但在3D Vis窗口周围添加额外的GUI元素.我想将libgdx(RoboVM)代码编译成框架或库可能是一个可以导入的解决方案?!
我一直在关注这个:https://code.google.com/p/table-layout/#Quickstart,以便对LibGDX中的表进行一些介绍.我已经用按钮试验了一下.
现在我有这个代码:
Label introLabel = new Label("Skip Intro", skin);
TextField introText = new TextField("", skin);
table.add(introLabel);
table.add(introText).width(100);
table.row();
Run Code Online (Sandbox Code Playgroud)
但它抛出一个NullPointerException
因为:No com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle registered with name: default
我只将我的按钮(从屏幕上的其他位置)添加到皮肤中:
atlas = new TextureAtlas("assets/gui/buttons/alpha_generic_buttons.pack");
skin = new Skin();
skin.addRegions(atlas);
Run Code Online (Sandbox Code Playgroud)
我现在的问题是桌子需要什么样的纹理,最重要的是,如何将它们与桌子一起使用?
对于我的游戏,我希望Android后退按钮带你进入暂停菜单,而不是最小化游戏.从我用谷歌搜索,我知道我需要打电话
Gdx.input.setCatchBackKey(true);
Run Code Online (Sandbox Code Playgroud)
但是我如何实际检查按钮按下?input.isKeyDown(Keys.BACK)似乎没有做任何事情.
我使用ShapeRenderer绘制了一个填充圆圈,现在我想将此圆绘制为透明圆.我使用以下代码来做到这一点:但是圆圈不是透明的.此外,我检查了libgdx API,并从维基,它说,需要创建CameraStrategy.有人曾经遇到过类似的问题吗?如果是这样,请给我一些线索.提前致谢.
Gdx.gl.glEnable(GL10.GL_BLEND);
Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
drawFilledCircle();
Gdx.gl.glDisable(GL10.GL_BLEND);
private void drawFilledCircle(){
shapeRenderer.setProjectionMatrix(camera.combined);
shapeRenderer.begin(ShapeType.FilledCircle);
shapeRenderer.setColor(new Color(0, 1, 0, 1));
shapeRenderer.filledCircle(470, 45, 10);
shapeRenderer.end();
}
Run Code Online (Sandbox Code Playgroud) 有谁知道如何在libGDX中使用TTF字体?我环顾四周,看过有关StbTrueTypeFont的事情,但它似乎没有出现在最新版本中.
编辑:我发现了StbTrueType字体的东西,jar文件位于extensions目录中.我已将它添加到我的项目中.现在我只需要弄清楚如何使用它.任何例子?
是否可以在libGdx(Android/Desktop的Java引擎)中使用SpriteBatch渲染到纹理?如果是这样,怎么办?
基本上我想将所有内容渲染到512 x 256纹理的320 x 240区域,而不是缩放区域以适合屏幕(在横向模式下).这样我想消除当我独立缩放alpha混合纹理时发生的伪像.如果有任何其他方法来删除这些工件,请指出它们:)
还有libGdx的在线文档吗?