Skip to content

How to use for android

Kojir0 edited this page Feb 10, 2013 · 1 revision

Your android game pom must contain :

<dependency>
      <groupId>fr.byob.game</groupId>
      <artifactId>box2d-android</artifactId>
      <version>${project.version}</version>
</dependency>
    
<dependency>
      <groupId>fr.byob.game</groupId>
      <artifactId>box2d-android-nativelib</artifactId>
      <version>${project.version}</version>
      <scope>runtime</scope>
      <type>so</type>
</dependency>

To create the box2d-android-nativelib depency do a mvn install:install-file on box2d-android :

mvn install:install-file 
-DgroupId=fr.byob.game 
-DartifactId=box2d-android-nativelib 
-Dversion=1.0-SNAPSHOT 
-Dfile=path\to\workspace\box2d\box2d-android\obj\local\armeabi\libgdx.so 
-Dpackaging=so
-Dpath=file://path\to\workspace\box2d\box2d-android\obj\local\armeabi\libgdx.so

Your playN Game class (playn.core.Game) must contains a fr.byob.game.box2d.Box2D instance. And your android game activity (playn.android.GameActivity) must run the game with the com.badlogic.gdx.physics.box2d.Box2D implementation. PlayN.run(new MyGame(new com.badlogic.gdx.physics.box2d.Box2D()));

So in your core game, you can use the fr.byob.game.box2d.Box2D interface to create the world, to create shapes, etc.

Sample code

Clone this wiki locally