Will Tice
Will Tice

Reputation: 433

Using a third-party library with libgdx and GWT

As I'm sure many others have, I've written my own game engine and am successfully using it with libgdx in my desktop project.

Now, it's time for me to get the HTML5 project working. I followed these directions to integrate my game engine, the "third-party library", into the HTML5 project. However, it hasn't gone smoothly. When I do GWT Compile, I get the following:

[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...)

Both GameObjectA and GameObjectB extend EngineObject, so obviously I'm quite confused by this output.

Foo is a class in the engine, so the bottom two errors don't make any sense either. How can it find com.me.engine.Foo.bar(EngineObject) in the first few errors but not be able to find com.me.engine in the last two errors? (And remember, this all works in the desktop project!)

The only conclusion I can make is that my project setup or GwtDefinition.gwt.xml is incorrect. I'm stumped as to where I've gone wrong though- any advice is greatly appreciated.

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>

I thought the "inherits name='Engine'" line was all I needed? Without it, I get a bunch of "No source code is available" errors, so I know I'm doing something right. (It also proves that it's finding the Engine's source!)

(Using JRE7)

Upvotes: 4

Views: 1479

Answers (1)

Neocy
Neocy

Reputation: 166

Add src element to your module gwt.xml

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

More info here -> DevGuidemodule

also make sure that your module is also packaged as source, along with compiled jar file, and both are available on the classpath.

Upvotes: 1

Related Questions