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


Java Controllers.addListener方法代码示例

本文整理汇总了Java中com.badlogic.gdx.controllers.Controllers.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java Controllers.addListener方法的具体用法?Java Controllers.addListener怎么用?Java Controllers.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.controllers.Controllers的用法示例。


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

示例1: preLoad

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public void preLoad()
{
	input = new InputManager(se);
	Controllers.addListener(input);
	
	atlas = new TextureAtlas("main.atlas");
	titleScreenAtlas = new TextureAtlas("titlescreen.atlas");
	menuControlsAtlas = new TextureAtlas("menu.atlas");
	menuFont = new BitmapFont(Gdx.files.internal("data/cgcfont.fnt"), atlas.findRegion("cgcfont"), false);
	titleFont = new BitmapFont(Gdx.files.internal("data/cgctitlefont.fnt"), atlas.findRegion("cgctitlefont"), false);
	sBatch = new SpriteBatch(1625);
	shapes = new ShapeRenderer();
	tManager = new TweenManager();

	FileHandle baseFileHandle = Gdx.files.internal("i18n/CGCLang");
	I18NBundle myBundle = I18NBundle.createBundle(baseFileHandle, locale);

	lang = myBundle;
	ChaseApp.alert("lang loaded");
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:21,代码来源:ChaseApp.java

示例2: InputHandlerOld

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public InputHandlerOld() {
    tempVec = new Vector2();

    activeContexts = new Array<>();
    activeKeyCodes = new ArrayMap<>();
    activePointers = new ArrayMap<>();
    activeMouseInputs = new ArrayMap<>();

    inputListeners = new Array<>();
    inputContexts = new ArrayMap<>();

    keyInputsMap = new ArrayMap<>();
    pointerInputsMap = new ArrayMap<>();
    stickInputsMap = new ArrayMap<>();
    mouseInputsMap = new ArrayMap<>();

    Controllers.addListener(this);

    inputMultiplexer = new InputMultiplexer(this);
    Gdx.input.setInputProcessor(inputMultiplexer);
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:22,代码来源:InputHandlerOld.java

示例3: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
	Array<Controller> controllers = Controllers.getControllers();
	if (controllers.size > 0) {
		controller = controllers.first();
	}
	Controllers.addListener(controllerListener);

	setScreen(new MainMenu(this));
	music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
	music.setLooping(true);
	music.play();
	Gdx.input.setInputProcessor(new InputAdapter() {
		@Override
		public boolean keyUp (int keycode) {
			if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
				Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
			}
			return true;
		}
	});

	fps = new FPSLogger();
}
 
开发者ID:Motsai,项目名称:neblina-libgdx3d,代码行数:25,代码来源:Invaders.java

示例4: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public void create() {
//		Texture.setEnforcePotImages(false);
		MyInputProcessor iP = new MyInputProcessor();
		Gdx.input.setInputProcessor(iP);
		Controllers.addListener(iP);

		res.loadTextures();
		res.loadMusic();
		res.loadScriptList(Gdx.files.internal("assets/scripts"));
		res.loadLevelNames();
		res.loadEventToTexture();

		cam = new Camera();
		cam.setToOrtho(false, width/scale, height/scale);
		hudCam = new OrthographicCamera();
		hudCam.setToOrtho(false, width/2, height/2);
		b2dCam = new Camera();
		b2dCam.setToOrtho(false, width/scale/PPM, height/scale/PPM);
		sb = new FadingSpriteBatch();
		gsm = new GameStateManager(this);
		
        if(Controllers.getControllers().size == 0)
            hasControllers = false;
        else hasControllers = true;
	}
 
开发者ID:JayKEm,项目名称:Aftamath,代码行数:26,代码来源:Game.java

示例5: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
	Array<Controller> controllers = Controllers.getControllers();
	if (controllers.size > 0) {
		controller = controllers.first();
	}
	Controllers.addListener(controllerListener);

	setScreen(new MainMenu(this));
	music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
	music.setLooping(true);
	music.play();
	Gdx.input.setInputProcessor(new InputAdapter() {
		@Override
		public boolean keyUp (int keycode) {
			if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
				if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
			}
			return true;
		}
	});

	fps = new FPSLogger();
}
 
开发者ID:konsoletyper,项目名称:teavm-libgdx,代码行数:25,代码来源:Invaders.java

示例6: createNinjaRabbit

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
 * Creates a new instance of {@link NinjaRabbit}, defining its graphical, audio and physical
 * properties.
 *
 * @param world
 *            The Box2D {@link World} onto which to create the {@link Body} and {@link Fixture}
 *            of the {@link Entity}.
 * @param loader
 *            A {@link BodyEditorLoader} to handle creation of the Entity body and fixtures.
 * @param assets
 *            The {@link AssetManager} from where to extract the graphical and audio resources.
 *            Those resources should be loaded in the manager before calling this method and
 *            won't be disposed.
 * @param status
 *            A reference to the global status of the player to be updated from the changes in
 *            the returned entity inner state.
 * @param observers
 *            An array of event receivers. Events will fire when the active player status
 *            changes (such as losing lives, collecting items, etc.).
 * @return A ready to use instance of a new {@link NinjaRabbit}.
 */
public static Entity createNinjaRabbit(final World world, final BodyEditorLoader loader, final AssetManager assets,
		final CurrentPlayerStatus status, final PlayerStatusObserver... observers) {
	PhysicsProcessor physics = new NinjaRabbitPhysicsProcessor();
	CONTACT_LISTENER.add(physics);
	world.setContactListener(CONTACT_LISTENER);
	GraphicsProcessor graphics = new NinjaRabbitGraphicsProcessor(assets);
	BodyProcessor bodyProcessor = new NinjaRabbitBodyProcessor(world, loader);
	AudioProcessor audio = new NinjaRabbitAudioProcessor(assets);
	PlayerStatusProcessor player = new NinjaRabbitPlayerStatusProcessor(status);
	if (observers != null) {
		for (PlayerStatusObserver o : observers) {
			player.addObserver(o);
		}
	}
	NinjaRabbit ninjaRabbit = new NinjaRabbit(player, bodyProcessor, graphics, physics, audio);

	if (Ouya.isRunningOnOuya()) {
		Controllers.clearListeners();
		Controllers.addListener(new NinjaRabbitControllerProcessor(ninjaRabbit));
	} else {
		Gdx.input.setInputProcessor(new NinjaRabbitInputProcessor(ninjaRabbit));
	}
	return ninjaRabbit;
}
 
开发者ID:nfantone,项目名称:ninja-rabbit,代码行数:46,代码来源:EntityFactory.java

示例7: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create () {
	Array<Controller> controllers = Controllers.getControllers();
	if (controllers.size > 0) {
		controller = controllers.first();
	}
	Controllers.addListener(controllerListener);

	setScreen(new MainMenu(this));
	music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3", FileType.Internal));
	music.setLooping(true);
	music.play();
	Gdx.input.setInputProcessor(new InputAdapter() {
		@Override
		public boolean keyUp (int keycode) {
			if (keycode == Keys.ENTER && Gdx.app.getType() == ApplicationType.WebGL) {
				if (!Gdx.graphics.isFullscreen()) Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayModes()[0]);
			}
			return true;
		}
	});

	fps = new FPSLogger();
}
 
开发者ID:jadref,项目名称:buffer_bci,代码行数:25,代码来源:Invaders.java

示例8: InputManager

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
 * Privater Konstruktor.
 *
 * Verhindert, dass von außen eine Instanz erstellt werden kann.
 */
private InputManager() {
    Controllers.addListener(this);

    controllerGameButtonBindingInverse = new HashMap<ButtonKey, Action>();
    controllerGameAxisBindingInverse = new HashMap<AxisKey, Action>();
    controllerGameAxisStateInverse = new HashMap<AxisKey, Boolean>();

    controllerGameButtonBinding = new HashMap<Action, ButtonKey[]>();
    controllerGameAxisBinding = new HashMap<Action, AxisKey[]>();
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:16,代码来源:InputManager.java

示例9: GamePadManager

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public GamePadManager() {
    Controllers.addListener(this);

    count = Controllers.getControllers().size;
    pads = new Controller[2];
    for(int i = 0; i < count; i++) {
        if(i > 1) break;
        pads[i] = Controllers.getControllers().get(i);
     }
}
 
开发者ID:elitej13,项目名称:project-divine-intervention,代码行数:11,代码来源:GamePadManager.java

示例10: setInputSource

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
public void setInputSource(Stage stage)
{
    multiInput = new InputMultiplexer();
    keyboardInput = new KeyboardInputProcessor();
    xboxInput = new XboxInputProcessor();
    
    multiInput.addProcessor(stage);
    multiInput.addProcessor(keyboardInput);
    multiInput.addProcessor(xboxInput);
    
    Controllers.addListener(xboxInput);
    Gdx.input.setInputProcessor(multiInput);
}
 
开发者ID:Aeo-Informatik,项目名称:Space-Bombs,代码行数:14,代码来源:InputHandler.java

示例11: setGameInput

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
 * automatically called when a gamestate gets active within a call to {@link #setGameState(GameStateType, boolean, boolean, Object)}
 * Sets the active inputadapter of the game. Each {@link GameStateLogic} instance is a {@link GameInputAdapter}
 * to listen to keyboard/mouse/touch/controller events.
 *  
 * @param gameInputAdapter active input adapater to listen to keyboard,mouse,touch and controller events
 */
private void setGameInput(GameInputAdapter gameInputAdapter) {
	if (currentInputAdapter != null) {
		// remove the previous inputadapter as Controllerlistener
		Controllers.removeListener(currentInputAdapter);
	}

	// set the active inputadapter as new libgdx inputprocessor to listen to keyboard,mouse and touch events
	Gdx.input.setInputProcessor(gameInputAdapter);
	// add the active inputadapter as Controllerlistener to listen to controller events
	Controllers.addListener(gameInputAdapter);
	// remember the active inputadapter for later to remove it as Controllerlistener if no longer needed
	currentInputAdapter = gameInputAdapter;
}
 
开发者ID:Quillraven,项目名称:Protoman-vs-Megaman,代码行数:21,代码来源:GDXGame.java

示例12: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void create() {
    Array<Controller> controllers = Controllers.getControllers();
    if (controllers.size > 0) {
        controller = controllers.first();
    }
    Controllers.addListener(controllerListener);

    setScreen(new MainMenu(this));
    music = Gdx.audio.newMusic(Gdx.files.getFileHandle("data/8.12.mp3",
            FileType.Internal));
    music.setLooping(true);
    music.play();
    Gdx.input.setInputProcessor(new InputAdapter() {
        @Override
        public boolean keyUp(int keycode) {
            if (keycode == Keys.ENTER
                    && Gdx.app.getType() == ApplicationType.WebGL) {
                if (!Gdx.graphics.isFullscreen())
                    Gdx.graphics.setDisplayMode(Gdx.graphics.getDisplayModes()[0]);
            }
            return true;
        }
    });

    fps = new FPSLogger();
}
 
开发者ID:jiangerji,项目名称:android-screen-recorder,代码行数:28,代码来源:Invaders.java

示例13: initGamePadControllers

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void initGamePadControllers() {
	for(Controller controller: Controllers.getControllers()) {
		   controllers.add(controller);
	}	
	
	Controllers.addListener(this);
}
 
开发者ID:pierotofy,项目名称:snappyfrog,代码行数:9,代码来源:OuyaServices.java

示例14: initialise

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void initialise(GameContainer gc) {
	Controllers.addListener(this);
	for(Controller controller : Controllers.getControllers()) {
		Gdx.app.log(LOGGING_TAG, "Detected: " + controller.getName());
	}
}
 
开发者ID:mini2Dx,项目名称:mini2Dx,代码行数:8,代码来源:ControllerMapping.java

示例15: create

import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
/**
 * LibGDX lifecycle callback for application initialization. Initializes
 * ggvm virtual machine, game-specific adapters, input processor, and
 * menu. Loads last save state if present and starts the vm.
 */
@Override
public void create() {
    Thread.currentThread().setUncaughtExceptionHandler(this);

    //Set up logging, window title and turn on vsync
    Gdx.app.setLogLevel(Gdx.app.LOG_INFO);
    Gdx.app.log(getClass().getSimpleName(), "create()");
    Gdx.graphics.setTitle(gameModule.provideTitle());
    Gdx.graphics.setVSync(true);

    //Initialize ggvm
    FileHandle fileHandle = Gdx.files.internal(gameModule.provideFileName());
    ggvm = new GGVm(gameModule.provideCartridge(fileHandle.readBytes()), gameModule.provideNmiSafeFunctor(), this);

    //Initialize game-specific classes that depend on ggvm
    rasterEffectManager = gameModule.provideRasterEffectManager(ggvm);
    soundtrackManager = gameModule.provideSoundtrackManager(ggvm);

    //Initialize input processor
    inputProcessor = InputProcessorBase.newInstance(
            inputProcessorClass,
            ggvm,
            gameModule.provideDpadFileName(),
            gameModule.provideSSFileName(),
            gameModule.provideABFileName());
    inputProcessor.create();
    inputProcessor.loadConfiguration();
    Gdx.input.setInputProcessor(inputProcessor);
    Controllers.addListener(inputProcessor);

    //Initialize menu manager
    menu = Menu.newInstance(menuClass);
    menu.setDependencies(gameModule.provideFontFileName(), gameModule.provideFontBitmapFileName(), ggvm, inputProcessor, soundtrackManager);
    menu.create();
    inputProcessor.setMenu(menu);

    //Get pattern table manager
    patternTableManager = gameModule.providePatternTableManager(ggvm);
    //Get render strategy and create all LibGDX objects
    renderManager = gameModule.provideRenderManager(ggvm, patternTableManager, rasterEffectManager);

    //Setup application level LibGDX objects
    spriteBatch = new SpriteBatch();

    loadState();

    //Generate graphics at least once in case we have a CHR-ROM mapper.
    patternTableManager.onGeneratePatternTable();

    ggvm.start();
}
 
开发者ID:gradualgames,项目名称:ggvm,代码行数:57,代码来源:GGVmApplication.java


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