use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class InterpolationTest method create.
@Override
public void create() {
Gdx.gl.glClearColor(.3f, .3f, .3f, 1);
renderer = new ShapeRenderer();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage(new ScreenViewport());
resetPositions();
Field[] interpolationFields = ClassReflection.getFields(Interpolation.class);
// see how many fields are actually interpolations (for safety; other fields may be added with future)
int interpolationMembers = 0;
for (int i = 0; i < interpolationFields.length; i++) if (ClassReflection.isAssignableFrom(Interpolation.class, interpolationFields[i].getDeclaringClass()))
interpolationMembers++;
// get interpolation names
interpolationNames = new String[interpolationMembers];
for (int i = 0; i < interpolationFields.length; i++) if (ClassReflection.isAssignableFrom(Interpolation.class, interpolationFields[i].getDeclaringClass()))
interpolationNames[i] = interpolationFields[i].getName();
selectedInterpolation = interpolationNames[0];
list = new List(skin);
list.setItems(interpolationNames);
list.addListener(new ChangeListener() {
public void changed(ChangeEvent event, Actor actor) {
selectedInterpolation = list.getSelected();
time = 0;
resetPositions();
}
});
ScrollPane scroll = new ScrollPane(list, skin);
scroll.setFadeScrollBars(false);
scroll.setScrollingDisabled(true, false);
table = new Table();
table.setFillParent(true);
table.add(scroll).expandX().left().width(100);
stage.addActor(table);
Gdx.input.setInputProcessor(new InputMultiplexer(new InputAdapter() {
public boolean scrolled(int amount) {
if (!Gdx.input.isKeyPressed(Keys.CONTROL_LEFT))
return false;
duration -= amount / 15f;
duration = MathUtils.clamp(duration, 0, Float.POSITIVE_INFINITY);
return true;
}
}, stage, new InputAdapter() {
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (// if "walking" was interrupted by this touch down event
!Float.isNaN(time))
// set startPosition to the current position
startPosition.set(getPosition(time));
targetPosition.set(stage.screenToStageCoordinates(targetPosition.set(screenX, screenY)));
time = 0;
return true;
}
}));
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class PixmapPackerTest method create.
@Override
public void create() {
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
camera.update();
Pixmap pixmap1 = new Pixmap(Gdx.files.internal("data/badlogic.jpg"));
Pixmap pixmap2 = new Pixmap(Gdx.files.internal("data/particle-fire.png"));
Pixmap pixmap3 = new Pixmap(Gdx.files.internal("data/isotile.png"));
PixmapPacker packer = new PixmapPacker(1024, 1024, Format.RGBA8888, 8, false);
for (int count = 1; count <= 3; ++count) {
packer.pack("badlogic " + count, pixmap1);
packer.pack("fire " + count, pixmap2);
packer.pack("isotile " + count, pixmap3);
}
atlas = packer.generateTextureAtlas(TextureFilter.Nearest, TextureFilter.Nearest, false);
Gdx.app.log("PixmapPackerTest", "Number of initial textures: " + atlas.getTextures().size);
packer.setPackToTexture(true);
for (int count = 4; count <= 10; ++count) {
packer.pack("badlogic " + count, pixmap1);
packer.pack("fire " + count, pixmap2);
packer.pack("isotile " + count, pixmap3);
}
pixmap1.dispose();
pixmap2.dispose();
pixmap3.dispose();
packer.updateTextureAtlas(atlas, TextureFilter.Nearest, TextureFilter.Nearest, false);
textureRegions = new Array<TextureRegion>();
packer.updateTextureRegions(textureRegions, TextureFilter.Nearest, TextureFilter.Nearest, false);
Gdx.app.log("PixmapPackerTest", "Number of updated textures: " + atlas.getTextures().size);
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
if (keycode >= Input.Keys.NUM_0 && keycode <= Input.Keys.NUM_9) {
int number = keycode - Input.Keys.NUM_0;
if (number < textureRegions.size) {
pageToShow = number;
}
}
return super.keyDown(keycode);
}
});
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class DelaunayTriangulatorTest method create.
public void create() {
renderer = new ShapeRenderer();
triangulate();
System.out.println(seed);
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
seed = MathUtils.random.nextLong();
System.out.println(seed);
triangulate();
return true;
}
public boolean mouseMoved(int screenX, int screenY) {
triangulate();
return false;
}
});
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class FilterPerformanceTest method create.
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;
}
});
}
use of com.badlogic.gdx.InputAdapter in project libgdx by libgdx.
the class BitmapFontAlignmentTest method create.
@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 = font.newFontCache();
layout = new GlyphLayout();
}
Aggregations