com.badlogic.gdx.Input.setCatchBackKey()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中com.badlogic.gdx.Input.setCatchBackKey()方法的一些代码示例,展示了Input.setCatchBackKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Input.setCatchBackKey()方法的具体详情如下:
包路径:com.badlogic.gdx.Input
类名称:Input
方法名:setCatchBackKey

Input.setCatchBackKey介绍

[英]Sets whether the BACK button on Android should be caught. This will prevent the app from being paused. Will have no effect on the desktop.
[中]设置是否应捕获Android上的后退按钮。这将防止应用程序暂停。将不会对桌面产生任何影响。

代码示例

代码示例来源:origin: libgdx/libgdx

@Override
public void setCatchBackKey (boolean catchBack) {
  input.setCatchBackKey(catchBack);
}

代码示例来源:origin: moribitotech/MTX

/**
 * Set the back button active for the screen. Sets
 * "Gdx.input.setCatchBackKey(true)" and override the method
 * "keyBackPressed" to add desired functionality to back button
 * 
 * @param isBackButtonActive
 *            to use or not to use the back button
 * @see keyBackPressed
 * 
 * */
public void setBackButtonActive(boolean isBackButtonActive) {
  Gdx.input.setCatchBackKey(isBackButtonActive);
  this.isBackButtonActive = isBackButtonActive;
  //
  MtxLogger.log(logActive, true, logTag, "SCREEN BACK BUTTON SET: "
      + getScreenName());
}

代码示例来源:origin: jmrapp1/SpaceInvaders

@Override
public void create() {
  sb = new SpriteBatch();
  sb.enableBlending();
  instantiateSettings();
  Gdx.input.setCatchBackKey(true); //Stops from exiting when back button pressed
}

代码示例来源:origin: manuelbua/uracer-kotd

public Input (Rectangle viewport, int keyFirstRepetitionDelayMs, int keyRepetitionSpeedMs) {
  this.viewport.set(viewport);
  releaseAllKeys();
  setKeyRepetitionMs(keyFirstRepetitionDelayMs, keyRepetitionSpeedMs);
  Gdx.input.setCatchBackKey(true);
}

代码示例来源:origin: com.harium.etyl/etyl-gdx

protected void init() {
  graphics = new GDXGraphics(w, h);
  graphics.setOrthographicCamera(orthoCamera);
  graphics.setProjectionMatrix(orthoCamera.combined);
  // Set default font
  FontLoader.getInstance().loadDefaultFont();
  graphics.setFont(FontLoader.getInstance().defaultFont());
  // Override Back Button Behavior
  // Without this, dispose and reload does not work well
  Gdx.input.setCatchBackKey(true);
  Gdx.input.setInputProcessor(this);
  initModules();
}

代码示例来源:origin: Mknsri/Drunk-Toss

@Override
public void create() {
  Art.loadArt();
  SoundLib.loadSoundLib();
  
  // Set options
  prefs = Gdx.app.getPreferences("ebingeimi-prefs");
  // Create a unique ID for leaderboards
  if (DrunkToss.prefs.getString("playerID") == "") {
    UUID playerID = UUID.randomUUID();
    DrunkToss.prefs.putString("playerID", playerID.toString());
    DrunkToss.prefs.flush();
  }
  
  camera = new OrthographicCamera(VIEWPORT_WIDTH,VIEWPORT_HEIGHT);
  camera.position.set(VIEWPORT_WIDTH / 2, VIEWPORT_HEIGHT / 2, 0);
  hudCamera = new OrthographicCamera(VIEWPORT_WIDTH,VIEWPORT_HEIGHT);
  hudCamera.position.set(VIEWPORT_WIDTH / 2, VIEWPORT_HEIGHT / 2, 0);
  
  
  Gdx.input.setInputProcessor(input);
  Gdx.input.setCatchBackKey(true);
  
  batch = new SpriteBatch();
  setScreen(new TitleScreen());
}

代码示例来源:origin: LonamiWebs/Klooni1010

@Override
public void create() {
  onDesktop = Gdx.app.getType().equals(Application.ApplicationType.Desktop);
  prefs = Gdx.app.getPreferences("io.github.lonamiwebs.klooni.game");
  // Load the best match for the skin (depending on the device screen dimensions)
  skin = SkinLoader.loadSkin();
  // Use only one instance for the theme, so anyone using it uses the most up-to-date
  Theme.skin = skin; // Not the best idea
  final String themeName = prefs.getString("themeName", "default");
  if (Theme.exists(themeName))
    theme = Theme.getTheme(themeName);
  else
    theme = Theme.getTheme("default");
  Gdx.input.setCatchBackKey(true); // To show the pause menu
  setScreen(new MainMenuScreen(this));
  String effectName = prefs.getString("effectName", "vanish");
  effectSounds = new HashMap<String, Sound>(EFFECTS.length);
  effect = EFFECTS[0];
  for (IEffectFactory e : EFFECTS) {
    loadEffectSound(e.getName());
    if (e.getName().equals(effectName)) {
      effect = e;
    }
  }
}

代码示例来源:origin: jmrapp1/SpaceInvaders

@Override
public void create() {
  sb = new SpriteBatch(150);
  sb.enableBlending();
  instantiateSettings();
  Gdx.input.setCatchBackKey(true); //Stops from exiting when back button pressed
  instantiateSettings();
  ResourceManager.getInstance().loadTexturedDrawable("player", "player.png");
  ResourceManager.getInstance().loadTexturedDrawable("enemy", "enemy.png");
  ResourceManager.getInstance().loadTexturedDrawable("missile", "missile.png");
  ScreenManager.setScreen(new GameScreen());
}

代码示例来源:origin: com.lwgame.gdx/lwgame-core

@Override
public void create () {
  I18NBundle.setExceptionOnMissingKey(false);
  I18NBundle.setSimpleFormatter(true);
  Gdx.app.getInput().setCatchBackKey(true);
  Lw.language = SimpleLanguageFactory.getDefault();
  Lw.skin = new Skin();
  Lw.assetManager = new AssetManager();
  Texture.setAssetManager(Lw.assetManager);
  Lw.uiManager = new UIManager(new ExtendViewport(getResolutionWidth(), getResolutionHeight()));
  onCreate();
}

代码示例来源:origin: com.lwgame.gdx/core

@Override
public void create () {
  I18NBundle.setExceptionOnMissingKey(false);
  I18NBundle.setSimpleFormatter(true);
  Gdx.app.getInput().setCatchBackKey(true);
  Lw.language = SimpleLanguageFactory.getDefault();
  Lw.skin = new Skin();
  Lw.assetManager = new AssetManager();
  Texture.setAssetManager(Lw.assetManager);
  Lw.uiManager = new UIManager(new ExtendViewport(getUIWidth(), getUIHeight()));
  onCreate();
}

代码示例来源:origin: tube42/drumon

public void onCreate(SceneManager mgr, Item bgc)
{
  ServiceProvider.init();
  // set size before loading assets
  onResize(World.sw, World.sh);
  World.bgc = bgc;
  load_assets();
  // update size once more
  onResize(World.sw, World.sh);
  // create mixer
  World.prog = new Program(DEF_AMPS);
  World.seq = new Sequencer(World.prog);
  final DeviceOutput dev = new DeviceOutput();
  World.mixer = new Mixer(dev);
  // set the default amps
  World.scene_drum = new DrumScene();
  World.scene_choice = new ChoiceScene();
  World.scene_choice2 = new Choice2Scene();
  World.scene_save = new SaveScene();
  World.mgr = mgr;
  World.mgr.setScene(World.scene_drum);
  // TEMP until we fix the code handling back:
  Gdx.input.setCatchBackKey(false);
  // start the mixer!
  World.mixer.start();
}

代码示例来源:origin: xietansheng/Game2048ForGDX

@Override
public void create() {
  // 设置 log 输出级别
  Gdx.app.setLogLevel(Application.LOG_DEBUG);
  // 为了不压扁或拉长图片, 按实际屏幕比例计算世界宽高
  worldWidth = Res.FIX_WORLD_WIDTH;
  worldHeight = Gdx.graphics.getHeight() * worldWidth / Gdx.graphics.getWidth();
  Gdx.app.log(TAG, "World Size: " + worldWidth + " * " + worldHeight);
  // 创建资源管理器
  assetManager = new AssetManager();
  // 加载资源
  assetManager.load(Res.ATLAS_PATH, TextureAtlas.class);
  assetManager.load(Res.BITMAP_FONT_PATH, BitmapFont.class);
  assetManager.load(Res.Audios.MOVE, Sound.class);
  assetManager.load(Res.Audios.MERGE, Sound.class);
  // 等待资源加载完毕
  assetManager.finishLoading();
  // 获取资源
  atlas = assetManager.get(Res.ATLAS_PATH, TextureAtlas.class);
  bitmapFont = assetManager.get(Res.BITMAP_FONT_PATH, BitmapFont.class);
  // 创建主游戏场景
  gameScreen = new GameScreen(this);
  // 设置当前场景
  setScreen(gameScreen);
  // 捕获返回键, 手动处理应用的退出(防止“弹出”帮助界面或对话框时按返回键退出应用)
  Gdx.input.setCatchBackKey(true);
}

代码示例来源:origin: Var3D/var3dframe

public void create() {
  save = Gdx.app.getPreferences(getProjectName());// 数据存储实例化
  Gdx.input.setCatchBackKey(true);// 劫持系统返回键
  multiplexer = new InputMultiplexer();// 触控实例化
  Gdx.input.setInputProcessor(multiplexer);//
  stageTop = new StageTop(this);
  stageTop.setOff();
  isMusic = save.getBoolean("isMusic", true);
  isSound = save.getBoolean("isSound", true);
  // 全球化字体方案
  if (bundle == null) bundle = new VBundle(var3dListener);
  // 创建一个默认动态文本
  FreeBitmapFont font = new FreeBitmapFont(this, paint==null?new FreePaint(getDefaultFontSize()):paint);
  font.appendText("01234567890LoadingC" + getHeap());
  fonts.put("font", font);
  setStageLoad(StageLoad.class);
  init();
  var3dListener.create();
  if (Gdx.app.getType() == Application.ApplicationType.Desktop) {
    Vector2 size = var3dListener.getAppScreenSize();
    int width = (int) size.x;
    int height = (int) size.y;
    if ((width == 1242 && height == 2688) || (width == 2688 && height == 1242)) {
      iphoneX = new TextureRegion(new Texture(var3dListener.getIphoneXPixmap("")));
    }
  }
}

代码示例来源:origin: lycying/c2d-engine

if (engineConfig.catchBackKey) Gdx.input.setCatchBackKey(true);

代码示例来源:origin: bladecoder/bladecoder-adventure-engine

Gdx.input.setCatchBackKey(true);

代码示例来源:origin: kbz/SIFTrain

Gdx.input.setCatchBackKey(true);

代码示例来源:origin: kbz/SIFTrain

Gdx.input.setCatchBackKey(true);

代码示例来源:origin: kbz/SIFTrain

Gdx.input.setCatchBackKey(true);

代码示例来源:origin: kbz/SIFTrain

Gdx.input.setCatchBackKey(true);

相关文章