本文整理汇总了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");
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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[]>();
}
示例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);
}
}
示例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);
}
示例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;
}
示例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();
}
示例13: initGamePadControllers
import com.badlogic.gdx.controllers.Controllers; //导入方法依赖的package包/类
@Override
public void initGamePadControllers() {
for(Controller controller: Controllers.getControllers()) {
controllers.add(controller);
}
Controllers.addListener(this);
}
示例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());
}
}
示例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();
}