Created
June 25, 2012 16:00
-
-
Save foobraco/2989431 to your computer and use it in GitHub Desktop.
How to create platform specific interfaces in PlayN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static interface myInterface { | |
void closeapp(); | |
void callvibrator(long miliduration); | |
} | |
public final myInterface myinterface; | |
public Dig(myInterface myinterface) { | |
this.myinterface = myinterface; | |
} | |
/* | |
And that's it, now you can call anywhere in your core the function callvibrator(100); | |
and it will activate the vibrator on android platform. | |
This example works with android only but it should't be much different in the other platforms. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final MyGame mygame = new MyGame(new AndroidCode()); | |
public class AndroidImplementation implements MyGame.myInterface { | |
@Override | |
public void closeapp() { | |
System.exit(0); | |
} | |
@Override | |
public void callvibrator(long miliduration) { | |
vib.vibrate(miliduration); | |
} | |
} | |
// and where you usually call PlayN.run(new MyGame()); now call | |
Playn.run(mygame new AndroidImplementation()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment