Created
March 31, 2013 02:07
-
-
Save foobraco/5279183 to your computer and use it in GitHub Desktop.
How to create an Android interface for the vibrator 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
import android.os.Vibrator; | |
public class AndroidVibrator implements MyGame.Vibrator_interface { | |
public Vibrator vib; | |
@Override | |
public void callvibrator(long miliduration){ | |
vib.vibrate(miliduration); | |
} | |
} |
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 class MyGame implements Game { | |
public Vibrator_interface vib; | |
public MyGame(Vibrator_interface _vibrator){ | |
vib = _vibrator; | |
} | |
} |
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
import your.package.name.MyGame; | |
public class MyGameActivity extends GameActivity { | |
AndroidVibrator andVib = new AndroidVibrator(); | |
@Override | |
public void main(){ | |
PlayN.run(new MyGame(andvib)); | |
} | |
} |
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 interface Vibrator_interface{ | |
void callvibrator(long miliduration); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment