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


Java InputAdapter类代码示例

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


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

示例1: create

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
public void create () {
	batch = new SpriteBatch();
	sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
	textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);

	atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
	texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true);
	texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
	setTextureFilter(0);
	setModeString();

	sprite = atlas.createSprite("map");
	sprite2 = new Sprite(texture, 0, 0, 855, 480);
	font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);

	Gdx.input.setInputProcessor(new InputAdapter() {
		public boolean touchDown (int x, int y, int pointer, int newParam) {
			mode++;
			if (mode == filters.length * 2) mode = 0;
			setTextureFilter(mode / 2);
			setModeString();
			return false;
		}
	});
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:FilterPerformanceTest.java

示例2: show

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void show() {
  super.show();

  initMenu();
  InputAdapter escape = new InputAdapter() {
    @Override
    public boolean keyDown(int keycode) {
      if (keycode == Keys.ESCAPE && canEscape) {
        resumeGame();
        return true;
      } else
        return false;
    }
  };
  Gdx.input.setInputProcessor(new InputMultiplexer(escape, stage));
}
 
开发者ID:guillaume-alvarez,项目名称:ShapeOfThingsThatWere,代码行数:18,代码来源:AbstractPausedScreen.java

示例3: setLevel

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void setLevel(
        @NotNull
                Level level) {
    if (this.ecsManager != null) {
        ecsManager.removeSystem(orderSystem);
        ecsManager.removeSystem(mainRenderSystem);
        ecsManager.removeSystem(lineSystem);
        ecsManager.removeSystem(orderRenderSystem);
        ecsManager.removeSystem(visualUpdateSystem);
        ecsManager.removeSystem(selectionControlSystem);
        ecsManager.removeSystem(commandUISystem);
        ecsManager.removeSystem(hudSystem);
    }
    
    this.level = level;
    
    camera.position.x = 0;
    camera.position.y = 0;
    
    level.setViewport(this);
    ecsManager = level.getECS();
    ecsManager.addSystem(orderSystem = new OrderSystem(level));
    
    ecsManager.addSystem(mainRenderSystem = new MainRenderSystem(batch));
    ecsManager.addSystem(lineSystem = new LineRenderSystem(batch));
    ecsManager.addSystem(orderRenderSystem = new OrderRenderSystem(batch));
    ecsManager.addSystem(visualUpdateSystem = new VisualUpdateSystem());
    ecsManager.addSystem(commandUISystem = new CommandUISystem(camera, batch, level));
    ecsManager.addSystem(selectionControlSystem = new SelectionSystem(camera, batch, commandUISystem, level.getPlayer1()
            .getTeam()));
    ecsManager.addSystem(hudSystem = new HUDSystem(batch, commandUISystem, level, screen));
    
    SpaceGame.getInstance().getEventBus().post(new BeginLevelEvent(level));
    
    if (gameInputAdapter != null) {
        SpaceGameClient.INSTANCE.getInputMultiplexer().removeProcessor(gameInputAdapter);
    }
    
    SpaceGameClient.INSTANCE.getInputMultiplexer().addProcessor(gameInputAdapter = new InputAdapter() {
        private final float STRENGTH = 0.95f;
        
        @Override
        public boolean scrolled(int amount) {
            if (viewportControllable) {
                if (amount > 0) {
                    camera.zoom *= STRENGTH;
                } else if (amount < 0) {
                    camera.zoom /= STRENGTH;
                }
            }
            return false;
        }
    });
}
 
开发者ID:SergeySave,项目名称:SpaceGame,代码行数:56,代码来源:GameScreen.java

示例4: Screen

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
public Screen(ScreenManager manager) {
    this.manager = manager;

    adapter = new InputAdapter() {
        @Override
        public boolean keyDown(int keycode) {
            if (keycode == Keys.ESCAPE)
                Gdx.app.exit();

            keyPressed = true;
            ScreenManager.multiplexer.removeProcessor(adapter);
            return true;
        }
    };

    ScreenManager.multiplexer.addProcessor(adapter);
}
 
开发者ID:GGJG2016,项目名称:EvilBunnyGod,代码行数:18,代码来源:Screen.java

示例5: getBackInputAdapter

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
protected InputAdapter getBackInputAdapter()
{
    return new InputAdapter()
    {
        @Override
        public boolean keyUp(int keycode)
        {
            switch (keycode)
            {
                case Input.Keys.ESCAPE:
                case Input.Keys.BACK:
                {
                    ScreenManager.removeScreen(Screen.this);
                    return true;
                }
            }
            return false;
        }
    };
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:21,代码来源:Screen.java

示例6: show

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void show()
{
    InputAdapter backInputAdapter = new InputAdapter()
    {
        @Override
        public boolean keyUp(int keycode)
        {
            switch (keycode)
            {
                case Input.Keys.ESCAPE:
                case Input.Keys.BACK:
                {
                
                    ScreenManager.removeScreen(TutorialScreen.this);
                    ScreenManager.removeScreen(TutorialScreen.this.gameScreen);
                    return true;
                }
            }
            return false;
        }
    };
    Gdx.input.setInputProcessor(new InputMultiplexer(this.stage, backInputAdapter));
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:25,代码来源:TutorialScreen.java

示例7: show

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void show()
{
    Gdx.input.setInputProcessor(new InputMultiplexer(this.stage, new InputAdapter()
    {
        @Override
        public boolean keyUp(int keycode)
        {
            switch (keycode)
            {
                case Input.Keys.ESCAPE:
                case Input.Keys.BACK:
                {
                    Gdx.app.exit();
                    return true;
                }
            }
            return false;
        }
    }));
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:22,代码来源:MenuScreen.java

示例8: show

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void show()
{
    InputAdapter enterInputAdapter = new InputAdapter()
    {
        @Override
        public boolean keyUp(int keycode)
        {
            switch (keycode)
            {
                case Input.Keys.ENTER:
                {
                    play(
                        IngameMenuScreen.this.level.getId(),
                        IngameMenuScreen.this.level.getDifficulty());
                    return true;
                }
            }
            return false;
        }
    };

    Gdx.input.setInputProcessor(new InputMultiplexer(
        this.stage,
        enterInputAdapter));
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:27,代码来源:IngameMenuScreen.java

示例9: getCloseInputAdapter

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
protected InputAdapter getCloseInputAdapter()
{
    return new InputAdapter()
    {
        @Override
        public boolean keyUp(int keycode)
        {
            switch (keycode)
            {
                case Input.Keys.ESCAPE:
                case Input.Keys.BACK:
                {
                    ScreenManager.removeScreen(IngameMenuScreen.this);
                    ScreenManager.removeScreen(IngameMenuScreen.this.gameScreen);
                    return true;
                }
            }
            return false;
        }
    };
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:22,代码来源:IngameMenuScreen.java

示例10: create

import com.badlogic.gdx.InputAdapter; //导入依赖的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

示例11: main

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
public static void main(String[] args) 
{
	LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
	
	new LwjglApplication(new Game(){
		@Override
		public void create() {
			
			// play a pd patch
			Pd.audio.create(new PdConfiguration());
			Pd.audio.open(Gdx.files.local("resources/test.pd"));
			
			// and sounds at the same time
			final Sound snd = Gdx.audio.newSound(Gdx.files.classpath("shotgun.wav"));
			snd.play();
			Gdx.input.setInputProcessor(new InputAdapter(){
				@Override
				public boolean touchDown(int screenX, int screenY, int pointer, int button) {
					snd.play();
					return true;
				}
			});
			
		}}, config);
	
}
 
开发者ID:mgsx-dev,项目名称:gdx-pd,代码行数:27,代码来源:AudioGdxSoundTest.java

示例12: create

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void create()
{
	super.create();
	
	inputs.addProcessor(new InputAdapter() {
		@Override
		public boolean keyDown(int keycode) {
			if (keycode == Keys.ESCAPE) {
				Gdx.app.exit();
			}
			
			return false;
		}
	});
			
	setClearColor(Color.LIGHT_GRAY);
}
 
开发者ID:Namek,项目名称:lets-code-game,代码行数:19,代码来源:LcgApp.java

示例13: create

import com.badlogic.gdx.InputAdapter; //导入依赖的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

示例14: create

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
@Override
public void create () {
	Gdx.input.setInputProcessor(new InputAdapter() {
		public boolean touchDown (int x, int y, int pointer, int newParam) {
			renderMode = (renderMode + 1) % 6;
			return false;
		}
	});

	spriteBatch = new SpriteBatch();
	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
	logoSprite = new Sprite(texture);
	logoSprite.setColor(1, 1, 1, 0.6f);
	logoSprite.setBounds(50, 100, 400, 100);

	font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle(
		"data/verdana39.png", FileType.Internal), false);
	cache = new BitmapFontCache(font);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:BitmapFontAlignmentTest.java

示例15: GenericInputComponent

import com.badlogic.gdx.InputAdapter; //导入依赖的package包/类
public GenericInputComponent ( EntityInterface entity ) {
    super(ComponentGroupManager.INPUT, entity);

    // todo: inject custom callbacks into InputComponents
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int x, int y, int pointer, int button) {
            float mx = x;
            float my = Gdx.graphics.getHeight() - y;

            /**
             * Larger Consideration:
             * Could implement "Spacial" Component that wraps x,y,z,velocity, angle, scale, etc
             * then simply, example: ((SpacialComponent)_entity.getComponent("Spacial")).getY()/.setX(x)
             * Considerations in this are, Performance trade-off vs Flexibility (consistency)
             * and then finally alternative Fast mapping techniques acheiving the same outcome
             */

            ((SpriteEntityInterface)_entity).setX(mx);
            ((SpriteEntityInterface)_entity).setY(my);
            return true;
        }

    });
}
 
开发者ID:sscholle,项目名称:PlanePilot,代码行数:26,代码来源:GenericInputComponent.java


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