-
Notifications
You must be signed in to change notification settings - Fork 0
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
- the core game https://github.com/Kojir0/memeduel/blob/master/core/src/main/java/fr/byob/game/memeduel/core/MemeDuel.java
- the android activity https://github.com/Kojir0/memeduel/blob/master/android/src/main/java/fr/byob/game/memeduel/android/MemeDuelActivity.java
- and a class that uses the Box2D interface https://github.com/Kojir0/memeduel/blob/master/core/src/main/java/fr/byob/game/memeduel/core/model/AbstractModel.java