Skip to content

Instantly share code, notes, and snippets.

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