本文整理汇总了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;
}
});
}
示例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));
}
示例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;
}
});
}
示例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);
}
示例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;
}
};
}
示例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));
}
示例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;
}
}));
}
示例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));
}
示例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;
}
};
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
});
}