Java Code Examples for com.badlogic.gdx.Application.ApplicationType#Android
The following examples show how to use
com.badlogic.gdx.Application.ApplicationType#Android .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GLTFDemo.java From gdx-gltf with Apache License 2.0 | 6 votes |
private void loadModelIndex() { rootFolder = Gdx.files.internal(samplesPath); String indexFilename = Gdx.app.getType() == ApplicationType.WebGL || Gdx.app.getType() == ApplicationType.Android ? "model-index-web.json" : "model-index.json"; FileHandle file = rootFolder.child(indexFilename); entries = new Json().fromJson(Array.class, ModelEntry.class, file); ui.entrySelector.setItems(entries); if(AUTOLOAD_ENTRY != null && AUTOLOAD_VARIANT != null){ for(int i=0 ; i<entries.size ; i++){ ModelEntry entry = entries.get(i); if(entry.name.equals(AUTOLOAD_ENTRY)){ ui.entrySelector.setSelected(entry); // will be auto select if there is only one variant. if(entry.variants.size != 1){ ui.variantSelector.setSelected(AUTOLOAD_VARIANT); } break; } } } }
Example 2
Source File: SpaceGame.java From libgdx-2d-tutorial with MIT License | 5 votes |
@Override public void create () { batch = new SpriteBatch(); cam = new GameCamera(WIDTH, HEIGHT); if (Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS) IS_MOBILE = true; IS_MOBILE = true; this.scrollingBackground = new ScrollingBackground(); this.setScreen(new MainMenuScreen(this)); }
Example 3
Source File: FileLoading.java From ud406 with MIT License | 5 votes |
public static String encrypt(String message) { try { Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] encryptedBytes = cipher.doFinal(message.getBytes()); if (Gdx.app.getType() == ApplicationType.Android){ throw new Exception("This demo works only with the desktop backend"); } return Base64.encodeBase64String(encryptedBytes); } catch (Exception e) { Gdx.app.error(TAG, "Couldn't encrypt message: " + message, e); } return "Failed"; }
Example 4
Source File: FileLoading.java From ud406 with MIT License | 5 votes |
public static String decrypt(String encrypted) { try { Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, key); if (Gdx.app.getType() == ApplicationType.Android){ throw new Exception("This demo works only with the desktop backend"); } byte[] encryptedBytes = Base64.decodeBase64(encrypted); return new String(cipher.doFinal(encryptedBytes)); } catch (Exception e) { Gdx.app.error(TAG, "Couldn't decrypt message: " + encrypted, e); } return "Failed"; }
Example 5
Source File: FileLoading.java From ud406 with MIT License | 5 votes |
public static String encrypt(String message) { try { Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, key); byte[] encryptedBytes = cipher.doFinal(message.getBytes()); if (Gdx.app.getType() == ApplicationType.Android){ throw new Exception("This demo works only with the desktop backend"); } return Base64.encodeBase64String(encryptedBytes); } catch (Exception e) { Gdx.app.error(TAG, "Couldn't encrypt message: " + message, e); } return "Failed"; }
Example 6
Source File: FileLoading.java From ud406 with MIT License | 5 votes |
public static String decrypt(String encrypted) { try { Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, key); if (Gdx.app.getType() == ApplicationType.Android){ throw new Exception("This demo works only with the desktop backend"); } byte[] encryptedBytes = Base64.decodeBase64(encrypted); return new String(cipher.doFinal(encryptedBytes)); } catch (Exception e) { Gdx.app.error(TAG, "Couldn't decrypt message: " + encrypted, e); } return "Failed"; }
Example 7
Source File: FileUtils.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
/** * For android, the exists method is very slow, this is a fast * implementation * * @return true if file exists */ public static boolean exists(FileHandle fh) { if (Gdx.app.getType() == ApplicationType.Android) { try { fh.read().close(); return true; } catch (Exception e) { return false; } } return fh.exists(); }
Example 8
Source File: GDXDialogsSystem.java From gdx-dialogs with Apache License 2.0 | 4 votes |
private void installAndroidGDXDialogs() { if (Gdx.app.getType() != ApplicationType.Android) { showDebugSkipInstall(ApplicationType.Android.name()); return; } if (Gdx.app.getType() == ApplicationType.Android) { try { Class<?> activityClazz = ClassReflection.forName("android.app.Activity"); Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.android.AndroidGDXDialogs"); Object activity = null; if (ClassReflection.isAssignableFrom(activityClazz, gdxAppObject.getClass())) { activity = gdxAppObject; } else { Class<?> supportFragmentClass = findClass("android.support.v4.app.Fragment"); // { if (supportFragmentClass != null && ClassReflection.isAssignableFrom(supportFragmentClass, gdxAppObject.getClass())) { activity = ClassReflection.getMethod(supportFragmentClass, "getActivity").invoke(gdxAppObject); } else { Class<?> fragmentClass = findClass("android.app.Fragment"); if (fragmentClass != null && ClassReflection.isAssignableFrom(fragmentClass, gdxAppObject.getClass())) { activity = ClassReflection.getMethod(fragmentClass, "getActivity").invoke(gdxAppObject); } } } if (activity == null) { throw new RuntimeException("Can't find your gdx activity to instantiate gdx-dialogs. " + "Looks like you have implemented AndroidApplication without using " + "Activity or Fragment classes or Activity is not available at the moment"); } Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz, activityClazz).newInstance(activity); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.Android.name()); } catch (Exception e) { showErrorInstall(ApplicationType.Android.name(), "android"); e.printStackTrace(); } } }
Example 9
Source File: GameplayScreen.java From ud406 with MIT License | 4 votes |
private boolean onMobile() { return Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS; }
Example 10
Source File: GameplayScreen.java From ud406 with MIT License | 4 votes |
private boolean onMobile() { return Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS; }
Example 11
Source File: GameplayScreen.java From ud406 with MIT License | 4 votes |
private boolean onMobile() { return Gdx.app.getType() == ApplicationType.Android || Gdx.app.getType() == ApplicationType.iOS; }
Example 12
Source File: OsUtils.java From vis-ui with Apache License 2.0 | 4 votes |
/** @return {@code true} if the current OS is Android */ public static boolean isAndroid () { return Gdx.app.getType() == ApplicationType.Android; }
Example 13
Source File: GameScreen.java From ashley-superjumper with Apache License 2.0 | 4 votes |
private void updateRunning (float deltaTime) { if (Gdx.input.justTouched()) { guiCam.unproject(touchPoint.set(Gdx.input.getX(), Gdx.input.getY(), 0)); if (pauseBounds.contains(touchPoint.x, touchPoint.y)) { Assets.playSound(Assets.clickSound); state = GAME_PAUSED; pauseSystems(); return; } } ApplicationType appType = Gdx.app.getType(); // should work also with Gdx.input.isPeripheralAvailable(Peripheral.Accelerometer) float accelX = 0.0f; if (appType == ApplicationType.Android || appType == ApplicationType.iOS) { accelX = Gdx.input.getAccelerometerX(); } else { if (Gdx.input.isKeyPressed(Keys.DPAD_LEFT)) accelX = 5f; if (Gdx.input.isKeyPressed(Keys.DPAD_RIGHT)) accelX = -5f; } engine.getSystem(BobSystem.class).setAccelX(accelX); if (world.score != lastScore) { lastScore = world.score; scoreString = "SCORE: " + lastScore; } if (world.state == World.WORLD_STATE_NEXT_LEVEL) { game.setScreen(new WinScreen(game)); } if (world.state == World.WORLD_STATE_GAME_OVER) { state = GAME_OVER; if (lastScore >= Settings.highscores[4]) scoreString = "NEW HIGHSCORE: " + lastScore; else scoreString = "SCORE: " + lastScore; pauseSystems(); Settings.addScore(lastScore); Settings.save(); } }