I need to offer slightly different app logic depending on the deployment platform my LibGDX app is running on, i.e. Desktop or Android, etc., does the LibGDX API offer a method of identifying the current runtime platform?
This post, "abstracting platform specific code in libGDX" offers a solution of sorts, I'm just wondering if there is something directly available in the API itself (?).
You could potentially use Application#getType()
, which will return one of the values defined by Application.ApplicationType
:
If people are having trouble figuring out where you actually get the ApplicationType from, it's accessed from:
Gdx.app.getType()
And for a working example this would do:
if(Gdx.app.getType() == ApplicationType.iOS) {
//Do awesome stuff for iOS here
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With