4

正如我确信许多其他人一样,我已经编写了自己的游戏引擎,并且在我的桌面项目中成功地将它与 libgdx 一起使用。

现在,是时候让 HTML5 项目运行起来了。我按照这些指示将我的游戏引擎“第三方库”集成到 HTML5 项目中。然而,事情并不顺利。当我进行 GWT 编译时,我得到以下信息:

[ERROR] Errors in 'file:/C:/Data/Development/Java/mygame/src/com/me/mygame/MyGameFoo.java'
[ERROR] Line 1329: The method bar(EngineObject) in the type Foo is not applicable for the arguments (GameObjectA)
[ERROR] Line 1333: The method bar(EngineObject) in the type Foo is not applicable for the arguments (GameObjectB)
[ERROR] Line 1340: The method bar(EngineObject) in the type Foo is not applicable for the arguments (GameObjectB)
[ERROR] Errors in 'file:/C:/Data/Development/Java/mygame/src/com/me/mygame/MyGameBar.java'
[ERROR] Line 3: The import com.me.engine cannot be resolved
[ERROR] Line 7: EngineObject cannot be resolved to a type
(and so on...)

GameObjectA 和 GameObjectB 都扩展了 EngineObject,所以显然我对这个输出感到很困惑。

Foo 是引擎中的一个类,因此底部的两个错误也没有任何意义。如何在前几个错误中找到 com.me.engine.Foo.bar(EngineObject) 而在后两个错误中找不到 com.me.engine?(请记住,这一切都适用于桌面项目!)

我能得出的唯一结论是我的项目设置或 GwtDefinition.gwt.xml 不正确。不过,我很困惑我哪里出错了——非常感谢任何建议。

GwtDefinition.gwt.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd">
<module>
    <inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' />
    <inherits name='com.badlogic.gdx.controllers' />
    <inherits name='com.badlogic.gdx.controllers.controllers-gwt' />
    <inherits name='Engine' />
    <inherits name='MyGame' />
    <entry-point class='com.me.mygame.client.GwtLauncher' />
    <set-configuration-property name="gdx.assetpath" value="../mygame-desktop/resources" />
</module>

我认为“inherits name='Engine'”行是我所需要的吗?没有它,我会收到一堆“没有可用的源代码”错误,所以我知道我做对了。(这也证明它正在寻找引擎的来源!)

(使用 JRE7)

4

1 回答 1

1

将 src 元素添加到您的模块 gwt.xml

< source path="your-translatable-code-path" />

更多信息在这里-> DevGuidemodule

还要确保您的模块也打包为源代码以及编译的 jar 文件,并且两者都在类路径中可用。

于 2013-12-08T14:42:56.597 回答