use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class ParticleEmittersTest method create.
@Override
public void create() {
spriteBatch = new SpriteBatch();
effect = new ParticleEffect();
effect.load(Gdx.files.internal("data/singleTextureAllAdditive.p"), Gdx.files.internal("data"));
effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
effectPool = new ParticleEffectPool(effect, 20, 20);
setupUI();
InputProcessor inputProcessor = new InputAdapter() {
public boolean touchDragged(int x, int y, int pointer) {
if (latestEffect != null)
latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
return false;
}
public boolean touchDown(int x, int y, int pointer, int newParam) {
latestEffect = effectPool.obtain();
latestEffect.setEmittersCleanUpBlendFunction(!skipCleanup.isChecked());
latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
effects.add(latestEffect);
return false;
}
};
InputMultiplexer multiplexer = new InputMultiplexer();
multiplexer.addProcessor(ui);
multiplexer.addProcessor(inputProcessor);
Gdx.input.setInputProcessor(multiplexer);
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class SoftKeyboardTest method create.
@Override
public void create() {
// we want to render the input, so we need
// a sprite batch and a font
batch = new SpriteBatch();
font = new BitmapFont();
textBuffer = new SimpleCharSequence();
// we register an InputAdapter to listen for the keyboard
// input. The on-screen keyboard might only generate
// "key typed" events, depending on the backend.
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyTyped(char character) {
// convert \r to \n
if (character == '\r')
character = '\n';
// if we get \b, we remove the last inserted character
if (character == '\b' && textBuffer.length() > 0) {
textBuffer.delete();
}
// else we just insert the character
textBuffer.add(character);
return true;
}
});
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class ViewportTest2 method create.
public void create() {
font = new BitmapFont();
font.setColor(0, 0, 0, 1);
Pixmap pixmap = new Pixmap(16, 16, Format.RGBA8888);
pixmap.setColor(1, 1, 1, 1);
pixmap.fill();
texture = new Texture(pixmap);
batch = new SpriteBatch();
camera = new OrthographicCamera();
camera.position.set(100, 100, 0);
camera.update();
viewports = ViewportTest1.getViewports(camera);
viewport = viewports.first();
names = ViewportTest1.getViewportNames();
name = names.first();
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.SPACE) {
int index = (viewports.indexOf(viewport, true) + 1) % viewports.size;
name = names.get(index);
viewport = viewports.get(index);
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
return false;
}
});
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class ViewportTest3 method create.
public void create() {
modelBatch = new ModelBatch();
modelBuilder = new ModelBuilder();
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.3f, 0.3f, 0.3f, 1.f));
shadowLight = new DirectionalLight();
shadowLight.set(0.8f, 0.8f, 0.8f, -0.5f, -1f, 0.7f);
environment.add(shadowLight);
modelBatch = new ModelBatch();
camera = new PerspectiveCamera();
camera.fieldOfView = 67;
camera.near = 0.1f;
camera.far = 300f;
camera.position.set(0, 0, 100);
camera.lookAt(0, 0, 0);
viewports = ViewportTest1.getViewports(camera);
viewport = viewports.first();
names = ViewportTest1.getViewportNames();
name = names.first();
ModelBuilder modelBuilder = new ModelBuilder();
Model boxModel = modelBuilder.createBox(50f, 50f, 50f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
boxInstance = new ModelInstance(boxModel);
boxInstance.transform.rotate(1, 0, 0, 30);
boxInstance.transform.rotate(0, 1, 0, 30);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.SPACE) {
int index = (viewports.indexOf(viewport, true) + 1) % viewports.size;
name = names.get(index);
viewport = viewports.get(index);
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
return false;
}
});
}
Aggregations