ãã¹ã¯ãããã¨android両ç¨ã§OpenGL ESãªã³ã¼ããæ¸ããlibgdxã®ä½¿ãæ¹
http://code.google.com/p/libgdx/
ã®HelloWorldããã¸ã§ã¯ããmaven管çã«ããæé ã
Windows7ä¸ã®cygwinããmavenã使ãç°å¢cygwin上でmavenを使う - 三次元日誌ã
ã¤ã³ã¹ãã¼ã«
libgdxã®ã¤ã³ã¹ãã¼ã«ã
http://code.google.com/p/libgdx/downloads/listãã
libgdx-0.9.2.zip
ãå
¥æããã
libgdxã¯mavenãªãã¸ããªãè¦å½ãããªãã®ã§ãã¢ã¼ã«ã¤ãã解åãã¦ãã¼ã«ã«ãªãã¸ããªã«ç»é²ããã
$ cd libgdx-0.9.2 # jarã®ã¤ã³ã¹ãã¼ã« $ for f in *.jar;do mvn install:install-file -Dfile=$f -DgroupId=com.badlogic.gdx -DartifactId=${f%%.jar} -Dversion=0.9.2 -Dpack aging=jar -DgeneratePom=true -DcreateChecksum=true; done # androidã®ndkã¤ã³ã¹ãã¼ã« $ cd armeabi $ for f in *.so;do mvn install:install-file -Dfile=$f -DgroupId=com.badlogic.gdx -DartifactId=${f%%.so} -Dversion=0.9.2 -Dpackaging=so -DgeneratePom=true -DcreateChecksum=true; done
maven2以åã«install:installã ã£ããã®ããmaven3ã§install:install-fileã«ãªã£ãã½ãã注æã
ããã¸ã§ã¯ãä½æ
ï¼ã¤ã®ãµãã¢ã¸ã¥ã¼ã«(æ¬ä½ããã¹ã¯ãããç¨ãã¢ã³ããã¤ãç¨)ãæã¤æ§æã«ããã
parent + common + desktop + android
ã¨ãããã
- groupId:jp.ousttrue.gdxsample
- artifactId:gdxxample
- version:1.0-SNAPSHOT
ã§ããã
$ mkdir gdxsample $ cd gdxsample
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>jp.ousttrue.gdxsample</groupId> <artifactId>gdxsample</artifactId> <version>1.0-SNAPSHOT</version> <packaging>pom</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <gdx.version>0.9.2</gdx.version> </properties> </project>
gdxã®helloworldãã²ãã
以éã¯gdx-helloworldã®ã½ã¼ã¹ãmavenããã¸ã§ã¯ãã§åãããã«é
ç½®ããæé
ã«ãªãã
http://code.google.com/p/libgdx/downloads/list
ãã
gdx-helloworld-0.9.2.zip
ãã²ããã
${HELLOWORLD}ã«è§£åããã¨ããã
commonãµãã¢ã¸ã¥ã¼ã«
ãµãã¢ã¸ã¥ã¼ã«ä½æ
$ mvn archetype:create -DgroupId=jp.ousttrue.gdxsample -DartifactId=common
commonãã£ã¬ã¯ããªã«ãµãã¢ã¸ã¥ã¼ã«çæããã¦pom.xmlã«
<modules> <module>common</module> </modules>
ã追è¨ãããã
$ rm common/src/main/java/jp/ousttrue/gdxsample/App.java $ rm common/src/test/java/jp/ousttrue/gdxsample/AppTest.java $ cp ${HELLOWORLD}/gdx-helloworld/src/com/badlogic/gdx/helloworld/HelloWorld.java common/src/main/java/jp/ousttrue/gdxsample/
HelloWorld.javaã®packageã調æ´
package jp.ousttrue.gdxsample;
common/pom.xmlã«gdxã«ä¾åã©ã¤ãã©ãªãè¨è¿°ãã
<dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx</artifactId> <version>${gdx.version}</version> <scope>compile</scope> </dependency>
ãã«ã確èª
$ mvn install
desktopãµãã¢ã¸ã¥ã¼ã«
ãµãã¢ã¸ã¥ã¼ã«ä½æ
$ mvn archetype:create -DgroupId=jp.ousttrue.gdxsample -DartifactId=desktop
$ rm desktop/src/main/java/jp/ousttrue/gdxsample/App.java $ rm desktop/src/test/java/jp/ousttrue/gdxsample/AppTest.java $ cp ${HELLOWORLD}/gdx-helloworld/src/com/badlogic/gdx/helloworld/HelloWorldDesktop.java.java common/src/main/java/jp/ousttrue/gdxsample/ $ mkdir data $ cp ${HELLOWORLD}/gdx-helloworld/data/badlogic.jpg data/
HelloWorld.javaã®packageã調æ´
package jp.ousttrue.gdxsample; import jp.ousttrue.gdxsample.HelloWorld;
desktop/pom.xmlã«gdxã«ä¾åã©ã¤ãã©ãªãè¨è¿°ãã
<!-- commonã®åç § --> <dependency> <groupId>jp.ousttrue.gdxsample</groupId> <artifactId>common</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!-- gdxã®desktopç¨ã©ã¤ãã©ãª --> <dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx-backend-jogl</artifactId> <version>${gdx.version}</version> <scope>compile</scope> </dependency>
ãã«ã確èª
$ mvn install
desktopå®è¡
desktop/pom.xmlã«è¿½è¨
<build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <configuration> <mainClass>jp.ousttrue.gdxsample.HelloWorldDesktop</mainClass> </configuration> </plugin> </plugins> </build>
desktop/pom.xmlã«gdxã«ä¾åã©ã¤ãã©ãªãè¨è¿°ãã
<!-- gdxã®desktopã©ã³ã¿ã¤ã --> <dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx-natives</artifactId> <version>${gdx.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.badlogic.gdx</groupId> <artifactId>gdx-backend-jogl-natives</artifactId> <version>${gdx.version}</version> <scope>runtime</scope> </dependency>
å®è¡
$ mvn -f desktop/pom.xml exec:java
"*-nativesã®-*.jar"ã®ä¸ã«ã¯dllãå
¥ã£ã¦ãããmvn exec:javaæã«/tmpã«ä¸æãã£ã¬ã¯ããªãä½ããã¦ä¸ã«dllãå±éãã¦ããã«pathãéãã¦ãããããã
androidã«ç¶ãã»ã»ã»