当前位置: 首页>>代码示例>>Java>>正文


Java LifecycleListener类代码示例

本文整理汇总了Java中com.badlogic.gdx.LifecycleListener的典型用法代码示例。如果您正苦于以下问题:Java LifecycleListener类的具体用法?Java LifecycleListener怎么用?Java LifecycleListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LifecycleListener类属于com.badlogic.gdx包,在下文中一共展示了LifecycleListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: end

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
/** 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);
}
 
开发者ID:Arcnor,项目名称:gdx-backend-jglfw,代码行数:18,代码来源:JglfwApplication.java

示例2: start

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
/**
 * @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");
        }
    });
}
 
开发者ID:anonl,项目名称:nvlist,代码行数:56,代码来源:DesktopLauncher.java

示例3: end

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
/** 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);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:14,代码来源:JglfwApplication.java

示例4: pause

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
public void pause () {
	if (appPaused) return;
	appPaused = true;

	Array<LifecycleListener> listeners = app.lifecycleListeners;
	synchronized (listeners) {
		for (LifecycleListener listener : listeners) {
			listener.pause();
		}
	}
	app.listener.pause();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:IOSGraphics.java

示例5: willTerminate

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:IOSApplication.java

示例6: stop

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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();
		}
	});
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:23,代码来源:LwjglCanvas.java

示例7: stop

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:38,代码来源:LwjglAWTCanvas.java

示例8: removeLifecycleListener

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
@Override
public void removeLifecycleListener (LifecycleListener listener) {
	synchronized (lifecycleListeners) {
		lifecycleListeners.removeValue(listener, true);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:LwjglAWTCanvas.java

示例9: OculusImplementation

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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();
		}
	});
}
 
开发者ID:nooone,项目名称:gdx-vr,代码行数:27,代码来源:OculusImplementation.java

示例10: addLifecycleListener

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
public void addLifecycleListener (LifecycleListener listener) {
	synchronized (lifecycleListeners) {
		lifecycleListeners.add(listener);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:6,代码来源:JglfwApplication.java

示例11: resume

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
public void resume () {
	if (!appPaused) return;
	appPaused = false;

	Array<LifecycleListener> listeners = app.lifecycleListeners;
	synchronized (listeners) {
		for (LifecycleListener listener : listeners) {
			listener.resume();
		}
	}
	app.listener.resume();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:13,代码来源:IOSGraphics.java

示例12: create

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
@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();
		}
	});
}
 
开发者ID:PhilippGrulich,项目名称:HAW-SE2-projecthorse,代码行数:30,代码来源:CoreGameMain.java

示例13: CardboardImplementation

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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();
		}
	});
}
 
开发者ID:nooone,项目名称:gdx-vr,代码行数:31,代码来源:CardboardImplementation.java

示例14: init

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
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);
      }
   }
}
 
开发者ID:raphaelbruno,项目名称:ZombieInvadersVR,代码行数:69,代码来源:CardBoardAndroidApplication.java

示例15: addLifecycleListener

import com.badlogic.gdx.LifecycleListener; //导入依赖的package包/类
@Override
public void addLifecycleListener (LifecycleListener listener) {
   synchronized (lifecycleListeners) {
      lifecycleListeners.add(listener);
   }
}
 
开发者ID:raphaelbruno,项目名称:ZombieInvadersVR,代码行数:7,代码来源:CardBoardAndroidApplication.java


注:本文中的com.badlogic.gdx.LifecycleListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。