Java 类com.badlogic.gdx.LifecycleListener 实例源码

项目:gdx-backend-jglfw    文件:JglfwApplication.java   
/** Called when the game loop has exited. */
protected void end () {
    synchronized (lifecycleListeners) {
        for (LifecycleListener listener : lifecycleListeners) {
            listener.pause();
            listener.dispose();
        }
    }
    listener.pause();
    listener.dispose();
    if (audio != null) {
        audio.dispose();
    }
    glfwReleaseCallbacks(graphics.window);
    glfwTerminate();
    if (forceExit) System.exit(-1);
}
项目:nvlist    文件:DesktopLauncher.java   
/**
 * @throws InitException If a fatal error occurs during initialization.
 */
public void start() throws InitException {
    DesktopGdxFileSystem gdxFileSystem = openResourceFileSystem(new File("."));
    IWritableFileSystem outputFileSystem = new DesktopOutputFileSystem(FileType.Local, "save/");

    final Launcher launcher = new Launcher(gdxFileSystem, outputFileSystem) {
        @Override
        public void create() {
            DesktopGraphicsUtil.setWindowIcon(gdxFileSystem);
            windowedSize = DesktopGraphicsUtil.limitInitialWindowSize(Gdx.graphics);

            super.create();
        }

        @Override
        public void resize(int width, int height) {
            super.resize(width, height);

            if (!Gdx.graphics.isFullscreen()) {
                windowedSize = Dim.of(width, height);
            }
        }

        @Override
        protected void handleInput(INativeInput input) {
            super.handleInput(input);

            DesktopLauncher.this.handleInput(input);
        }
    };

    NovelPrefsStore prefs = launcher.loadPreferences();
    handleCommandlineOptions(prefs);

    Lwjgl3ApplicationConfiguration config = createConfig(launcher, prefs);
    Lwjgl3Application app = new Lwjgl3Application(launcher, config);
    app.addLifecycleListener(new LifecycleListener() {
        @Override
        public void resume() {
            LOG.info("App resume");
        }

        @Override
        public void pause() {
            LOG.info("App pause");
        }

        @Override
        public void dispose() {
            LOG.info("App dispose");
        }
    });
}
项目:libgdxcn    文件:JglfwApplication.java   
/** Called when the game loop has exited. */
protected void end () {
    synchronized (lifecycleListeners) {
        for (LifecycleListener listener : lifecycleListeners) {
            listener.pause();
            listener.dispose();
        }
    }
    listener.pause();
    listener.dispose();
    glfwTerminate();
    if (forceExit) System.exit(-1);
}
项目:libgdxcn    文件:IOSGraphics.java   
public void pause () {
    if (appPaused) return;
    appPaused = true;

    Array<LifecycleListener> listeners = app.lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.pause();
        }
    }
    app.listener.pause();
}
项目:libgdxcn    文件:IOSApplication.java   
final void willTerminate (UIApplication uiApp) {
    Gdx.app.debug("IOSApplication", "disposed");
    graphics.makeCurrent();
    Array<LifecycleListener> listeners = lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.pause();
        }
    }
    listener.dispose();
    Gdx.gl.glFlush();
}
项目:libgdxcn    文件:LwjglCanvas.java   
public void stop () {
    EventQueue.invokeLater(new Runnable() {
        public void run () {
            if (!running) return;
            running = false;
            try {
                Display.destroy();
                if (audio != null) audio.dispose();
            } catch (Throwable ignored) {
            }
            Array<LifecycleListener> listeners = lifecycleListeners;
            synchronized (listeners) {
                for (LifecycleListener listener : listeners) {
                    listener.pause();
                    listener.dispose();
                }
            }
            listener.pause();
            listener.dispose();
        }
    });
}
项目:libgdxcn    文件:LwjglAWTCanvas.java   
public void stop () {
    if (!running) return;
    running = false;
    setGlobals();
    Array<LifecycleListener> listeners = lifecycleListeners;

    // To allow destroying of OpenGL textures during disposal.
    if (canvas.isDisplayable()) {
        makeCurrent();
    } else {
        error(logTag, "OpenGL context destroyed before application listener has had a chance to dispose of textures.");
    }

    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.pause();
            listener.dispose();
        }
    }
    listener.pause();
    listener.dispose();

    Gdx.app = null;

    Gdx.graphics = null;

    if (audio != null) {
        audio.dispose();
        Gdx.audio = null;
    }

    if (files != null) Gdx.files = null;

    if (net != null) Gdx.net = null;

    stopped();
}
项目:libgdxcn    文件:LwjglAWTCanvas.java   
@Override
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:gdx-vr    文件:OculusImplementation.java   
public OculusImplementation() {
    VirtualReality.implementation = this;

    VirtualReality.head = new Head();
    VirtualReality.body = new Body();
    VirtualReality.renderer = new VirtualRealityRenderer();

    OvrLibrary.INSTANCE.ovr_Initialize();
    hmd = OvrLibrary.INSTANCE.ovrHmd_CreateDebug(0);
    VirtualReality.headMountedDisplay = new OculusHMD(hmd);

    Gdx.app.addLifecycleListener(new LifecycleListener() {
        @Override
        public void resume() {
        }

        @Override
        public void pause() {
        }

        @Override
        public void dispose() {
            OvrLibrary.INSTANCE.ovr_Shutdown();
        }
    });
}
项目:mini2Dx    文件:IOSMini2DxGraphics.java   
public void pause () {
    if (appPaused) return;
    appPaused = true;

    Array<LifecycleListener> listeners = app.lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.pause();
        }
    }
    app.listener.pause();
}
项目:mini2Dx    文件:IOSMini2DxGame.java   
final void willTerminate (UIApplication uiApp) {
    Gdx.app.debug("IOSApplication", "disposed");
    graphics.makeCurrent();
    Array<LifecycleListener> listeners = lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.pause();
        }
    }
    listener.dispose();
    Gdx.gl.glFlush();
}
项目:libgdxcn    文件:JglfwApplication.java   
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:IOSGraphics.java   
public void resume () {
    if (!appPaused) return;
    appPaused = false;

    Array<LifecycleListener> listeners = app.lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.resume();
        }
    }
    app.listener.resume();
}
项目:HAW-SE2-projecthorse    文件:CoreGameMain.java   
@Override
public final void create() {
    splash = new SplashScreen();
    this.setScreen(splash);
    loadGame();

    Gdx.app.addLifecycleListener(new LifecycleListener() {

        @Override
        public void resume() {
            Gdx.app.log("LifecycleListener", "resume");

        }

        @Override
        public void pause() {
            Gdx.app.log("LifecycleListener", "pause");

        }

        @Override
        public void dispose() {
            Gdx.app.log("LifecycleListener", "dispose");
            GameManagerFactory.getInstance().getSettings().dispose();
            AudioManagerImpl.getInstance().dispose();
            AssetManager.disposeAll();
        }
    });
}
项目:gdx-vr    文件:CardboardImplementation.java   
public CardboardImplementation(Activity activity) {
    VirtualReality.implementation = this;

    VirtualReality.head = new Head();
    VirtualReality.body = new Body();
    VirtualReality.renderer = new VirtualRealityRenderer();

    headTracker = new HeadTracker(activity);
    headTracker.startTracking();

    HeadMountedDisplay hmd = new HeadMountedDisplay(activity.getWindowManager().getDefaultDisplay());
    VirtualReality.headMountedDisplay = new CardboardHMD(hmd);

    VirtualReality.distortionRenderer = new CardboardDistortionRenderer(hmd, new DistortionRenderer());

    Gdx.app.addLifecycleListener(new LifecycleListener() {
        @Override
        public void resume() {
        }

        @Override
        public void pause() {
        }

        @Override
        public void dispose() {
            headTracker.stopTracking();
        }
    });
}
项目:mini2Dx    文件:IOSMini2DxGraphics.java   
public void resume () {
    if (!appPaused) return;
    appPaused = false;

    Array<LifecycleListener> listeners = app.lifecycleListeners;
    synchronized (listeners) {
        for (LifecycleListener listener : listeners) {
            listener.resume();
        }
    }
    app.listener.resume();
}
项目:ZombieInvadersVR    文件:CardBoardAndroidApplication.java   
private void init (ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) {
   if (this.getVersion() < MINIMUM_SDK) {
      throw new GdxRuntimeException("LibGDX requires Android API Level " + MINIMUM_SDK + " or later.");
   }
   graphics = new CardBoardGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy()
      : config.resolutionStrategy);
   input = AndroidInputFactory.newAndroidInput(this, this, graphics.view, config);
   audio = new AndroidAudio(this, config);
   this.getFilesDir(); // workaround for Android bug #10515463
   files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());
   net = new AndroidNet(this);
   this.listener = listener;
   this.handler = new Handler();
   this.useImmersiveMode = config.useImmersiveMode;
   this.hideStatusBar = config.hideStatusBar;

   // Add a specialized audio lifecycle listener
   addLifecycleListener(new LifecycleListener() {

      @Override
      public void resume () {
         // No need to resume audio here
      }

      @Override
      public void pause () {
         audio.pause();
      }

      @Override
      public void dispose () {
         audio.dispose();
      }
   });

   Gdx.app = this;
   Gdx.input = this.getInput();
   Gdx.audio = this.getAudio();
   Gdx.files = this.getFiles();
   Gdx.graphics = this.getGraphics();
   Gdx.net = this.getNet();

   if (!isForView) {
      try {
         requestWindowFeature(Window.FEATURE_NO_TITLE);
      } catch (Exception ex) {
         log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", ex);
      }
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
      setContentView(graphics.getView(), createLayoutParams());
      setCardboardView((CardboardView)graphics.getView());
   }

   createWakeLock(config.useWakelock);
   hideStatusBar(this.hideStatusBar);
   useImmersiveMode(this.useImmersiveMode);
   if (this.useImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) {
      try {
         Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener");
         Object o = vlistener.newInstance();
         Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class);
         method.invoke(o, this);
      } catch (Exception e) {
         log("AndroidApplication", "Failed to create AndroidVisibilityListener", e);
      }
   }
}
项目:ZombieInvadersVR    文件:CardBoardAndroidApplication.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
   synchronized (lifecycleListeners) {
      lifecycleListeners.add(listener);
   }
}
项目:ZombieInvadersVR    文件:CardBoardAndroidApplication.java   
@Override
public void removeLifecycleListener (LifecycleListener listener) {
   synchronized (lifecycleListeners) {
      lifecycleListeners.removeValue(listener, true);
   }
}
项目:ZombieInvadersVR    文件:CardBoardAndroidApplication.java   
@Override
public SnapshotArray<LifecycleListener> getLifecycleListeners () {
   return lifecycleListeners;
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
private void init(ApplicationListener listener, AndroidApplicationConfiguration config, boolean isForView) {
    if (this.getVersion() < MINIMUM_SDK) {
        throw new GdxRuntimeException("LibGDX requires Android API Level " + MINIMUM_SDK + " or later.");
    }
    graphics = new AndroidGraphics(this, config, config.resolutionStrategy == null ? new FillResolutionStrategy()
            : config.resolutionStrategy);
    input = AndroidInputFactory.newAndroidInput(this, this.getContext(), graphics.getView(), config);
    audio = new AndroidAudio(this.getContext(), config);
    this.getContext().getFilesDir(); // workaround for Android bug #10515463
    files = new AndroidFiles(this.getContext().getAssets(), this.getContext().getFilesDir().getAbsolutePath());
    net = new AndroidNet(this);
    this.listener = listener;
    this.handler = new Handler();
    this.useImmersiveMode = config.useImmersiveMode;
    this.hideStatusBar = config.hideStatusBar;

    // Add a specialized audio lifecycle listener
    addLifecycleListener(new LifecycleListener() {

        @Override
        public void resume() {
            // No need to resume audio here
        }

        @Override
        public void pause() {
            audio.pause();
        }

        @Override
        public void dispose() {
            audio.dispose();
        }
    });

    Gdx.app = this;
    Gdx.input = this.getInput();
    Gdx.audio = this.getAudio();
    Gdx.files = this.getFiles();
    Gdx.graphics = this.getGraphics();
    Gdx.net = this.getNet();

    if (!isForView) {
        try {
            supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        } catch (Exception ex) {
            log("AndroidApplication", "Content already displayed, cannot request FEATURE_NO_TITLE", ex);
        }

        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        setContentView(graphics.getView(), createLayoutParams());
    }

    createWakeLock(config.useWakelock);
    hideStatusBar(this.hideStatusBar);
    useImmersiveMode(this.useImmersiveMode);
    if (this.useImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) {
        try {
            Class<?> vlistener = Class.forName("com.badlogic.gdx.backends.android.AndroidVisibilityListener");
            Object o = vlistener.newInstance();
            Method method = vlistener.getDeclaredMethod("createListener", AndroidApplicationBase.class);
            method.invoke(o, this);
        } catch (Exception e) {
            log("AndroidApplication", "Failed to create AndroidVisibilityListener", e);
        }
    }
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
@Override
public void addLifecycleListener(LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
@Override
public Array<LifecycleListener> getLifecycleListeners() {
    return lifecycleListeners;
}
项目:gdx-backend-jglfw    文件:JglfwApplication.java   
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:gdx-backend-jglfw    文件:JglfwApplication.java   
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:nvlist    文件:GdxAppStub.java   
@Override
public void addLifecycleListener(LifecycleListener listener) {
    // Doesn't have a lifecycle
}
项目:nvlist    文件:GdxAppStub.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    // Doesn't have a lifecycle
}
项目:teavm-libgdx    文件:TeaVMApplication.java   
@Override
public void addLifecycleListener(LifecycleListener listener) {
    lifecycleListeners.add(listener);
}
项目:teavm-libgdx    文件:TeaVMApplication.java   
@Override
public void removeLifecycleListener(LifecycleListener listener) {
    lifecycleListeners.remove(listener);
}
项目:libgdxcn    文件:JglfwApplication.java   
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:libgdxcn    文件:GwtApplication.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized(lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:HeadlessApplication.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:HeadlessApplication.java   
@Override
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:libgdxcn    文件:IOSApplication.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:IOSApplication.java   
@Override
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:libgdxcn    文件:LwjglCanvas.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:LwjglCanvas.java   
@Override
public void removeLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.removeValue(listener, true);
    }
}
项目:libgdxcn    文件:LwjglAWTCanvas.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}
项目:libgdxcn    文件:LwjglApplication.java   
@Override
public void addLifecycleListener (LifecycleListener listener) {
    synchronized (lifecycleListeners) {
        lifecycleListeners.add(listener);
    }
}