本文整理匯總了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;
}
});
}