Game Development Reference
In-Depth Information
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.gwt.GwtApplication;
import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration;
public class GwtLauncher extends GwtApplication {
@Override
public GwtApplicationConfiguration getConfig () {
GwtApplicationConfiguration cfg = new
GwtApplicationConfiguration(800, 480);
return cfg;
}
@Override
public ApplicationListener getApplicationListener () {
return new MyDemo();
}
}
In the preceding code listing, you can see the GwtLauncher class that is inherited
from the GwtApplication class. LibGDX encapsulates GWT and only requires you to
implement the two abstract methods, getConfig() and getApplicationListener() .
The getConfig() method returns an instance of the GwtApplicationConfiguration
class. In this case, the window's width and height are directly passed on to its
constructor. The getApplicationListener() method returns an instance of a class
that implements the ApplicationListener interface, which is the MyDemo class in
the preceding code.
Additionally, GWT is organized in so-called modules that bundle together all the
configuration settings. In this case, we only have one module called MyDemo.gwt.
xml . It defines the source path where GWT should look for Java source files, in this
case, com/packtpub/libgdx/demo . These source files will then be cross-compiled by
GWT to optimize the JavaScript code that is runnable on all major web browsers.
The following listing is MyDemo.gwt.xml from demo project:
<?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>
<source path="com/packtpub/libgdx/demo" />
</module>
 
Search WWH ::




Custom Search