Java 类com.badlogic.gdx.InputAdapter 实例源码
项目:libgdxcn
文件:FilterPerformanceTest.java
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;
}
});
}
项目:ShapeOfThingsThatWere
文件:AbstractPausedScreen.java
@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));
}
项目:SpaceGame
文件:GameScreen.java
@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;
}
});
}
项目:EvilBunnyGod
文件:Screen.java
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);
}
项目:space-travels-3
文件:Screen.java
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;
}
};
}
项目:space-travels-3
文件:TutorialScreen.java
@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));
}
项目:space-travels-3
文件:MenuScreen.java
@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;
}
}));
}
项目:space-travels-3
文件:IngameMenuScreen.java
@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));
}
项目:space-travels-3
文件:IngameMenuScreen.java
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;
}
};
}
项目:neblina-libgdx3d
文件:Invaders.java
@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();
}
项目:gdx-pd
文件:AudioGdxSoundTest.java
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);
}
项目:lets-code-game
文件:LcgApp.java
@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);
}
项目:teavm-libgdx
文件:Invaders.java
@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();
}
项目:libgdxcn
文件:BitmapFontAlignmentTest.java
@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);
}
项目:PlanePilot
文件:GenericInputComponent.java
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;
}
});
}
项目:libgdx-demo-invaders
文件:Invaders.java
@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();
}
项目:buffer_bci
文件:Invaders.java
@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.setFullscreenMode(Gdx.graphics.getDisplayModes()[0]);
}
return true;
}
});
fps = new FPSLogger();
}
项目:radial
文件:PhysicsRenderExample.java
@Override
public void show() {
super.show();
Context context = super.getContext();
context.getInputMultiplexer().addProcessor(new InputAdapter() {
@Override
public boolean keyDown(int keycode) {
if (keycode == Input.Keys.D) {
debugMode = !debugMode;
}
return true;
}
});
World world = context.getWorld();
populate(world);
}
项目:anathema-roguelike
文件:InteractiveUIElement.java
public T run() {
Game.getInstance().getUserInterface().addUIElement(this);
setResult(null);
KeyHandler keyHandler = new KeyHandler() {
@Override
public void handle(char key, boolean alt, boolean ctrl, boolean shift) {
if(key == SquidInput.ESCAPE) {
if(isCancellable()) {
finish();
}
} else {
processKeyEvent(key, alt, ctrl, shift);
}
}
};
InputAdapter mouse = new InputAdapter() {
@Override
public boolean scrolled(int amount) {
return processScrollEvent(amount);
}
};
Game.getInstance().getInput().proccessInput(new InputHandler(keyHandler, mouse), () -> { return isFinished(); }, () -> {
for(InteractiveUIElement<?> element : CollectionUtils.filterByClass(getUIElements(), InteractiveUIElement.class)) {
element.registerMouseCallbacks();
}
});
Game.getInstance().getUserInterface().removeUIElement(this);
return getResult();
}
项目:Battle-City-Multiplayer
文件:CoreBC.java
public static void changeScreen(Screen screen) {
if (INSTANCE.getScreen() != null) {
INSTANCE.getScreen().dispose();
}
INSTANCE.setScreen(screen);
screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
if (screen instanceof InputAdapter) {
Gdx.input.setInputProcessor((InputAdapter) screen);
}
}
项目:space-travels-3
文件:GameScreen.java
@Override
public void show()
{
this.level.resume();
Gdx.input.setInputProcessor(new InputAdapter()
{
@Override
public boolean keyUp(int keycode)
{
switch (keycode)
{
case Input.Keys.BACK:
case Input.Keys.MENU:
case Input.Keys.ESCAPE:
{
GameScreen.this.level.pause();
ScreenManager.addScreen(new GamePauseMenuScreen(
GameScreen.this.level,
GameScreen.this));
return true;
}
}
return false;
}
});
}
项目:gdx-lml
文件:Core.java
private static void addInputProcessor() {
// Closing the application as soon as it's clicked.
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean touchUp(final int screenX, final int screenY, final int pointer, final int button) {
GdxUtilities.exit();
return true;
}
});
}
项目:android-screen-recorder
文件:Invaders.java
@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();
}
项目:libgdxcn
文件:SoftKeyboardTest.java
@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;
}
});
}
项目:libgdxcn
文件:BitmapFontFlipTest.java
@Override
public void create () {
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int x, int y, int pointer, int newParam) {
renderMode = (renderMode + 1) % 4;
return false;
}
});
spriteBatch = new SpriteBatch();
spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
logoSprite = new Sprite(texture);
logoSprite.flip(false, true);
logoSprite.setPosition(0, 320 - 256);
logoSprite.setColor(1, 1, 1, 0.5f);
font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true);
cache1 = new BitmapFontCache(font);
cache2 = new BitmapFontCache(font);
cache3 = new BitmapFontCache(font);
cache4 = new BitmapFontCache(font);
cache5 = new BitmapFontCache(font);
createCaches("cached", cache1, cache2, cache3, cache4, cache5);
font.setScale(1.33f);
cacheScaled1 = new BitmapFontCache(font);
cacheScaled2 = new BitmapFontCache(font);
cacheScaled3 = new BitmapFontCache(font);
cacheScaled4 = new BitmapFontCache(font);
cacheScaled5 = new BitmapFontCache(font);
createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5);
}
项目:libgdxcn
文件:ViewportTest1.java
public void create () {
stage = new Stage();
Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
label = new Label("", skin);
Table root = new Table(skin);
root.setFillParent(true);
root.setBackground(skin.getDrawable("default-pane"));
root.debug().defaults().space(6);
root.add(new TextButton("Button 1", skin));
root.add(new TextButton("Button 2", skin)).row();
root.add("Press spacebar to change the viewport:").colspan(2).row();
root.add(label).colspan(2);
stage.addActor(root);
viewports = getViewports(stage.getCamera());
names = getViewportNames();
stage.setViewport(viewports.first());
label.setText(names.first());
Gdx.input.setInputProcessor(new InputMultiplexer(new InputAdapter() {
public boolean keyDown (int keycode) {
if (keycode == Input.Keys.SPACE) {
int index = (viewports.indexOf(stage.getViewport(), true) + 1) % viewports.size;
label.setText(names.get(index));
Viewport viewport = viewports.get(index);
stage.setViewport(viewport);
resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
return false;
}
}, stage));
}
项目:libgdxcn
文件:ViewportTest2.java
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;
}
});
}
项目:PlanePilot
文件:MotionBlurDemo.java
@Override
public void create() {
grass = new Texture(Gdx.files.internal("shaders/shockwave/grass.png"));
guy = new Texture(Gdx.files.internal("shaders/shockwave/guy.png"));
ShaderProgram.pedantic = false;
blurShader = new ShaderProgram(Gdx.files.internal("shaders/blur/gaussianVert.glsl").readString(), Gdx.files.internal("shaders/blur/gaussianFrag.glsl").readString());
//ensure it compiled
if (!blurShader.isCompiled())
throw new GdxRuntimeException("Could not compile shader: "+blurShader.getLog());
//print any warnings
if (blurShader.getLog().length()!=0)
System.out.println(blurShader.getLog());
fbo = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
fboTexRegion = new TextureRegion(fbo.getColorBufferTexture());
fboTexRegion.flip(false, true);
batch = new SpriteBatch(1000);
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.setToOrtho(false);
//handle mouse wheel
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
//System.out.println("screenx: "+screenX);
time = 0;
mouseX = (float)screenX / (float)Gdx.graphics.getWidth();
mouseY = 1.0f - (float)screenY / (float)Gdx.graphics.getHeight();
return true;
}
});
}
项目:PlanePilot
文件:GaussianBlurDemo.java
@Override
public void create() {
grass = new Texture(Gdx.files.internal("shaders/shockwave/grass.png"));
guy = new Texture(Gdx.files.internal("shaders/shockwave/guy.png"));
ShaderProgram.pedantic = false;
blurShader = new ShaderProgram(Gdx.files.internal("shaders/blur/gaussianVert.glsl").readString(), Gdx.files.internal("shaders/blur/gaussianFrag.glsl").readString());
//ensure it compiled
if (!blurShader.isCompiled())
throw new GdxRuntimeException("Could not compile shader: "+blurShader.getLog());
//print any warnings
if (blurShader.getLog().length()!=0)
System.out.println(blurShader.getLog());
fbo = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
fboTexRegion = new TextureRegion(fbo.getColorBufferTexture());
fboTexRegion.flip(false, true);
batch = new SpriteBatch(1000);
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.setToOrtho(false);
//handle mouse wheel
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
//System.out.println("screenx: "+screenX);
time = 0;
mouseX = (float)screenX / (float)Gdx.graphics.getWidth();
mouseY = 1.0f - (float)screenY / (float)Gdx.graphics.getHeight();
return true;
}
});
}
项目:PlanePilot
文件:ShockwaveDemo.java
@Override
public void create() {
grass = new Texture(Gdx.files.internal("shaders/shockwave/grass.png"));
guy = new Texture(Gdx.files.internal("shaders/shockwave/guy.png"));
ShaderProgram.pedantic = false;
blurShader = new ShaderProgram(Gdx.files.internal("shaders/blur/gaussianVert.glsl").readString(), Gdx.files.internal("shaders/blur/gaussianFrag.glsl").readString());
shader = new ShaderProgram(Gdx.files.internal("shaders/shockwave/shockVert.glsl").readString(), Gdx.files.internal("shaders/shockwave/shockFrag.glsl").readString());
//ensure it compiled
if (!shader.isCompiled())
throw new GdxRuntimeException("Could not compile shader: "+shader.getLog());
//print any warnings
if (shader.getLog().length()!=0)
System.out.println(shader.getLog());
fbo = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
fboTexRegion = new TextureRegion(fbo.getColorBufferTexture());
fboTexRegion.flip(false, true);
batch = new SpriteBatch(1000);
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.setToOrtho(false);
//handle mouse wheel
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
//System.out.println("screenx: "+screenX);
time = 0;
mouseX = (float)screenX / (float)Gdx.graphics.getWidth();
mouseY = 1.0f - (float)screenY / (float)Gdx.graphics.getHeight();
return true;
}
});
}
项目:PlanePilot
文件:Shockwave.java
@Override
public void create() {
grass = new Texture(Gdx.files.internal("shaders/shockwave/grass.png"));
guy = new Texture(Gdx.files.internal("shaders/shockwave/guy.png"));
ShaderProgram.pedantic = false;
blurShader = new ShaderProgram(Gdx.files.internal("shaders/blur/gaussianVert.glsl").readString(), Gdx.files.internal("shaders/blur/gaussianFrag.glsl").readString());
shader = new ShaderProgram(Gdx.files.internal("shaders/shockwave/shockVert.glsl").readString(), Gdx.files.internal("shaders/shockwave/shockFrag.glsl").readString());
//ensure it compiled
if (!shader.isCompiled())
throw new GdxRuntimeException("Could not compile shader: "+shader.getLog());
//print any warnings
if (shader.getLog().length()!=0)
System.out.println(shader.getLog());
fbo = new FrameBuffer(Pixmap.Format.RGBA8888, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
fboTexRegion = new TextureRegion(fbo.getColorBufferTexture());
fboTexRegion.flip(false, true);
batch = new SpriteBatch(1000);
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.setToOrtho(false);
//handle mouse wheel
Gdx.input.setInputProcessor(new InputAdapter() {
public boolean touchDown (int screenX, int screenY, int pointer, int button) {
//System.out.println("screenx: "+screenX);
time = 0;
mouseX = (float)screenX / (float)Gdx.graphics.getWidth();
mouseY = 1.0f - (float)screenY / (float)Gdx.graphics.getHeight();
return true;
}
});
}
项目:c2d-engine
文件:ActionShake.java
@Override
public InputProcessor getInputProcessor() {
return new InputAdapter() {
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
shake();
return super.touchUp(x, y, pointer, button);
}
};
}
项目:c2d-engine
文件:SceneB.java
@Override
public InputProcessor getInputProcessor() {
return new InputAdapter() {
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
Engine.setMainScene(SceneA.getInstance(), ((AbstractTransiton) Engine.get()).b2a());
return super.touchUp(x, y, pointer, button);
}
};
}
项目:c2d-engine
文件:SceneA.java
@Override
public InputProcessor getInputProcessor() {
return new InputAdapter() {
@Override
public boolean touchUp(int x, int y, int pointer, int button) {
Engine.setMainScene(SceneB.getInstance(), ((AbstractTransiton) Engine.get()).a2b());
return super.touchUp(x, y, pointer, button);
}
};
}
项目:buffer_bci
文件:BlankWaitKeyScreen.java
public BlankWaitKeyScreen() {
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp(int keycode) {
if(active) {
setDuration(0); // Force finish.
}
return true;
}
});
}
项目:buffer_bci
文件:InstructWaitKeyScreen.java
public InstructWaitKeyScreen(String instruction) {
super(instruction);
Gdx.input.setInputProcessor(new InputAdapter() {
@Override
public boolean keyUp(int keycode) {
if (active) {
setDuration(0); // Force finish.
}
return true;
}
});
}
项目:pmd
文件:GpuShadows.java
@Override
public void create() {
batch = new SpriteBatch();
ShaderProgram.pedantic = false;
//read vertex pass-through shader
final String VERT_SRC = Gdx.files.internal("data/pass.vert").readString();
// renders occluders to 1D shadow map
shadowMapShader = createShader(VERT_SRC, Gdx.files.internal("data/shadowMap.frag").readString());
// samples 1D shadow map to create the blurred soft shadow
shadowRenderShader = createShader(VERT_SRC, Gdx.files.internal("data/shadowRender.frag").readString());
//the occluders
casterSprites = new Texture("data/cat4.png");
//the light sprite
light = new Texture("data/light.png");
//build frame buffers
occludersFBO = new FrameBuffer(Format.RGBA8888, lightSize, lightSize, false);
occluders = new TextureRegion(occludersFBO.getColorBufferTexture());
occluders.flip(false, true);
//our 1D shadow map, lightSize x 1 pixels, no depth
shadowMapFBO = new FrameBuffer(Format.RGBA8888, lightSize, 1, false);
Texture shadowMapTex = shadowMapFBO.getColorBufferTexture();
//use linear filtering and repeat wrap mode when sampling
shadowMapTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
shadowMapTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
//for debugging only; in order to render the 1D shadow map FBO to screen
shadowMap1D = new TextureRegion(shadowMapTex);
shadowMap1D.flip(false, true);
font = new BitmapFont();
cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
cam.setToOrtho(false);
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;
lights.add(new Light(mx, my, randomColor()));
return true;
}
public boolean keyDown(int key) {
if (key==Keys.SPACE){
clearLights();
return true;
} else if (key==Keys.A){
additive = !additive;
return true;
} else if (key==Keys.S){
softShadows = !softShadows;
return true;
}
return false;
}
});
clearLights();
}
项目:kreativity-ui
文件:UiDemo.java
@Override
public void create() {
gl.glEnable(GL_BLEND);
gl.glDepthMask(true);
gl.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl.glClearColor(0.3f, 0.3f, 0.3f, 1);
KrToolkit.initialize(new KrLwjgl3Backend());
Gdx.input.setInputProcessor((InputAdapter) getDefaultToolkit().getInputSource());
canvas = KrToolkit.getDefaultToolkit().getCanvas();
darkGray = getDefaultToolkit().getDrawable(rgb(0x434343));
darkerGray = getDefaultToolkit().getDrawable(rgb(0x393939));
lightGray = rgb(0xaaaaaa);
testPopup = createPopup();
canvas.addInputListener((widget, event) -> {
if (event instanceof KrMouseEvent) {
KrMouseEvent mouseEvent = (KrMouseEvent) event;
if (mouseEvent.getType() == KrMouseEvent.Type.PRESSED && mouseEvent.getButton() == KrMouseEvent.Button.RIGHT) {
testPopup.show(mouseEvent.getScreenPosition());
}
if (widget == canvas.getRootPanel() && mouseEvent.getType() == KrMouseEvent.Type.PRESSED && mouseEvent.getButton() == KrMouseEvent.Button.LEFT) {
testPopup.hide();
}
}
});
KrDemoPanel demoPanel = new KrDemoPanel();
canvas.getRootPanel().setLayout(new KrBorderLayout());
canvas.getRootPanel().add(demoPanel, KrBorderLayout.Constraint.CENTER);
demoPanel.addChild(createButtons(), 0);
demoPanel.addChild(createGridLayout(), 0);
demoPanel.addChild(createCheckbox(), 0);
demoPanel.addChild(createSlider(), 0);
demoPanel.addChild(createHorizontalFlowLayoutPanel(), 1);
demoPanel.addChild(createVerticalFlowLayoutPanel(), 1);
demoPanel.addChild(createBorderLayoutPanel(), 1);
demoPanel.addChild(createCardLayout(), 1);
demoPanel.addChild(createScrollBarsPanel(), 2);
demoPanel.addChild(createScrollPanel(), 2);
demoPanel.addChild(createListView(), 2);
demoPanel.addChild(createTableView(), 2);
demoPanel.addChild(createSplitPanel(), 3);
demoPanel.addChild(createCollapsiblePanel(), 3);
demoPanel.addChild(createCollapsiblePanel(), 3);
// canvas.getRootPanel().add(createSandbox());
}
项目:anathema-roguelike
文件:InputHandler.java
public InputHandler(KeyHandler keyHandler) {
this.keyHandler = keyHandler;
this.mouse = new InputAdapter();
}
项目:anathema-roguelike
文件:InputHandler.java
public InputHandler(KeyHandler keyHandler, InputAdapter mouse) {
this.keyHandler = keyHandler;
this.mouse = mouse;
}