简体   繁体   English

在不带Gradle的RoboVM上设置LibGDX(仅获取黑屏)

[英]Setting up LibGDX on RoboVM without Gradle (getting black screen only)

I have a working cross-platform app that always ran fine under RoboVM. 我有一个可以正常运行的跨平台应用程序,在RoboVM下始终可以正常运行。 I started moving the graphics backend of the app over to LibGDX. 我开始将应用程序的图形后端移至LibGDX。 Everything runs fine under LWJGL but I can't get LibGDX to work on RoboVM. 在LWJGL下一切正常,但是我不能让LibGDX在RoboVM上工作。

I really don't feel like installing and learning yet another build-tool or dependency management thing, so I would like to get this working without having to use Gradle. 我真的不想安装和学习另一种构建工具或依赖项管理知识,因此我希望无需使用Gradle就可以使它正常工作。

Here's what I did so far: 这是我到目前为止所做的:

  • Downloaded the latest LibGDX release (1.6.1) from the releases directory . 发行目录下载了最新的LibGDX版本(1.6.1)。
  • Unpacked the zip-file into some directory on my computer (not in my Eclipse project). 将zip文件解压缩到计算机上的某个目录中(而不是在Eclipse项目中)。
  • Created a new user library in Eclipse containing these external jars from the folder: 在Eclipse中创建了一个新的用户库,其中包含来自文件夹的以下外部jar:
    gdx.jar , gdx-backend-robovm.jar , and gdx-natives.jar gdx.jargdx-backend-robovm.jargdx-natives.jar
  • Added the user library to my project. 将用户库添加到我的项目中。
  • Created a folder called libs in the root of my RoboVM project. 在RoboVM项目的根目录中创建了一个名为libs的文件夹。
  • Copied the iOS folder from the libgdx folder into libs containing the following files: iOS文件夹从libgdx文件夹复制到包含以下文件的libs中:
    libgdx.a and libObjectAL.a libgdx.alibObjectAL.a
  • Added a <libs> , a <frameworks> , and a <forceLinkClasses> section to my project's robovm.xml, which now looks like this: 在我项目的robovm.xml文件中添加了<libs><frameworks><forceLinkClasses>部分,现在如下所示:

     <config> <executableName>${app.executable}</executableName> <mainClass>${app.mainclass}</mainClass> <os>ios</os> <arch>thumbv7</arch> <resources> <resource> <directory>resources</directory> <skipPngCrush>true</skipPngCrush> </resource> </resources> <libs> <lib>libs/ios/libgdx.a</lib> <lib>libs/ios/libObjectAL.a</lib> </libs> <frameworks> <framework>UIKit</framework> <framework>OpenGLES</framework> <framework>QuartzCore</framework> <framework>CoreGraphics</framework> <framework>OpenAL</framework> <framework>AudioToolbox</framework> <framework>AVFoundation</framework> </frameworks> <forceLinkClasses> <pattern>com.badlogix.gdx.scenes.scene2d.ui.*</pattern> </forceLinkClasses> <target>ios</target> <iosInfoPList>Info.plist.xml</iosInfoPList> </config> 
  • Added the following code to my main method: 在我的主要方法中添加了以下代码:

     IOSApplicationConfiguration cfg = new IOSApplicationConfiguration(); cfg.orientationLandscape = true; cfg.orientationPortrait = true; new IOSApplication(getApplicationListener(), cfg); System.out.println("Should be ready..."); 

where getApplicationListener() returns the same object as in my LWGJL app. 其中getApplicationListener()返回与我的LWGJL应用程序中相同的对象。
The create() method in this object begins with System.out.println("Hello?"); 此对象中的create()方法以System.out.println("Hello?"); .

When I run the app, it launches (launch image and all) and starts playing some sound effects (not using LibGDX!) but just displays a black screen. 当我运行该应用程序时,它会启动(启动图像和所有图像)并开始播放一些音效(不使用LibGDX!),但仅显示黑屏。 It prints "Should be ready..." but it does not print "Hello?". 它打印“应该准备好...”,但不打印“ Hello?”。 So, the ApplicationListener gets created fine and the IOSApplication gets created fine, but the listener's create() method is never called. 因此,可以很好地创建ApplicationListener ,并且可以很好地创建IOSApplication ,但是从不调用侦听器的create()方法。 As always, there are no helpful (or any for that matter) error messages... 与往常一样,没有任何有用的(或与此相关的)错误消息...

Am I missing something??? 我想念什么吗???

I am pretty certain that the .a files got included in the build, because as soon as I added the <libs> section to robovm.xml, I got flooded with build errors that went away as soon as I also added the <frameworks> section. 我可以肯定.a文件已包含在构建中,因为一旦我将<libs>部分添加到robovm.xml中,我就充满了构建错误,而我也添加了<frameworks>就消失了部分。 Is there some other export setting that I need to worry about? 我还有其他需要担心的导出设置吗? Is there a way to at least get some sort of error or log message? 有没有办法至少获得某种错误或日志消息?

UPDATE : 更新

If I run it in the simulator, I also get a black screen. 如果我在模拟器中运行它,也会出现黑屏。 But if I click on the black screen, I get the following error message: 但是,如果我单击黑屏,则会收到以下错误消息:

unexpected nil window in _UIApplicationHandleEventFromQueueEvent, _windowServerHitTestWindow: <UIClassicWindow: 0x7fafa27175b0; frame = (0 0; 375 667); userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x7fafa2514d70>; layer = <UIWindowLayer: 0x7fafa2718060>>

I imported the LibGDX test projects into my Eclipse/RoboVM setup and those work fine... 我将LibGDX测试项目导入到我的Eclipse / RoboVM安装程序中,这些工作正常。

SO stupid: 这么笨:

The main class must extend IOSApplication.Delegate instead of UIApplicationDelegateAdapter . 主类必须扩展IOSApplication.Delegate而不是UIApplicationDelegateAdapter

6 hours wasted... And this is why I hate using external libraries rather than coding as close to the metal as possible (hence my earlier question ): To the person who writes the library, such a trivial thing will immediately become self-understood, automated, and forgotten. 浪费了6个小时...这就是为什么我讨厌使用外部库,而不是使用尽可能接近金属的代码(因此我较早的问题 ):对于编写该库的人来说,这样一件琐碎的事情会立即变得容易理解,自动化且被遗忘。 Therefore: No documentation, no useful error messages, no other checks and balances. 因此:没有文档,没有有用的错误消息,没有其他制衡方法。 Do a search for "libgdx IOSApplication.Delegate" and see if you can find a page that says that this is what one needs to do. 搜索“ libgdx IOSApplication.Delegate”,看是否可以找到一个页面,上面写着这是需要做的。 The only place it shows up is in some of the example codes where your attention immediately jumps to the content of the methods rather than the boilerplate that out of the corner of your eye looks the same as always anyways... But I'll stop here... Only the second sentence is really relevant to this answer anyways... 它显示的唯一位置是在某些示例代码中,您的注意力立即跳到了方法的内容上,而不是样板样的东西,无论如何,它们始终与您眼前一亮...但是我会停下来这里...反正只有第二句话与这个答案确实相关...

But, hey, we finally have a detailed description of how to add LibGDX to an existing project in RoboVM without using Gradle... 但是,嘿,我们终于详细介绍了如何在不使用Gradle的情况下将LibGDX添加到RoboVM中的现有项目中...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM