本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.InputListener类的典型用法代码示例。如果您正苦于以下问题:Java InputListener类的具体用法?Java InputListener怎么用?Java InputListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputListener类属于com.badlogic.gdx.scenes.scene2d包,在下文中一共展示了InputListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
@Override
public void create () {
camera = new OrthographicCamera();
camera.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
stage = new Stage();
stage.addListener(new InputListener(){
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button){
stage.getActors().get(counter).addAction(Actions.moveTo(x-50,y-50,1));
counter++;
if(counter==stage.getActors().size) {
counter=0;
}
return true;
}
});
Gdx.input.setInputProcessor(stage);
}
示例2: addTouchListener
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public void addTouchListener() {
this.addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (isHighlighted()) {
setHighlighted(false);
} else {
setHighlighted(true);
}
event.stop();
return true;
}
});
}
示例3: show
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
@Override
public void show() {
player = new Player(Assets.random());
client = new Client(player);
stage = new Stage();
Image logo = new Image(Assets.LOGO);
logo.setPosition((Gdx.graphics.getWidth() - logo.getWidth()) / 2, Gdx.graphics.getHeight() * 0.85f);
Image shadow = dropShadow(logo);
stage.addActor(logo);
stage.addActor(shadow);
stage.addActor(new PlayGroup(client));
stage.getRoot().addCaptureListener(new InputListener() {
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
if (!(event.getTarget() instanceof TextField)) stage.setKeyboardFocus(null);
return true;
}
});
Gdx.input.setInputProcessor(stage);
}
示例4: TabSelector
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public TabSelector(final int slotNum, Texture[] icons, final boolean isVertical, int defaultSlot) {
if(slotNum != icons.length)
throw new IllegalArgumentException("Icon array length needs to equal slot quantity");
setTouchable(Touchable.enabled);
slot = defaultSlot;
this.slotNum = slotNum;
this.isVertical = isVertical;
this.icons = icons;
selection = new Texture("theme/basic/ui/SelectionBox.png");
addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if(isVertical)
slot = (int)(y / (getHeight() / slotNum));
else
slot = (int)(x / (getWidth() / slotNum));
return true;
}
});
}
示例5: initButtons
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public void initButtons(int score,TextureAtlas buttonAtlas) {
Skin buttonSkin = new Skin();
buttonSkin.addRegions(buttonAtlas);
//TODO FIX THIS SHIT INDENTATION
//TODO Long-term fix the magic numbers
ImageButton playButton = new ImageButton(buttonSkin.getDrawable("playbutton"),
buttonSkin.getDrawable("playbutton"));
playButton.setSize(256, 64);
playButton.setPosition(screenSize.width/2-playButton.getWidth()/2,
screenSize.height/2-playButton.getHeight()/2+50);
playButton.addListener(new InputListener() {
@Override
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
polymorph.setScreen(new GameScreen(polymorph));
DeathScreenMusic.stop();
return true;
}
});
stage.addActor(playButton);
}
示例6: config_loading_stage
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
private void config_loading_stage() {
// TODO Auto-generated method stub
loading_stage = new Stage(managment_viewport, batch);
loading_stage.addActor(logo_actor);
loading_stage.addActor(loading_background_actor);
loading_stage.addActor(loading_actor);
loading_stage.addListener(new InputListener(){
@Override
public boolean keyDown(InputEvent event, int keycode) {
// TODO Auto-generated method stub
if(keycode == Keys.BACK){
back_button_down();
}
return true;
}
});
}
示例7: addPreviewProperties
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
private void addPreviewProperties(Table bottom, InputListener scrollPaneListener) {
Label label = new Label("Preview Properties", getSkin(), "title");
bottom.add(label);
bottom.row();
previewPropertiesTable = new Table();
previewPropertiesTable.defaults().pad(5.0f);
ScrollPane scrollPane = new ScrollPane(previewPropertiesTable, getSkin());
scrollPane.setFadeScrollBars(false);
scrollPane.setFlickScroll(false);
scrollPane.addListener(scrollPaneListener);
bottom.add(scrollPane).grow().padTop(10.0f).padBottom(10.0f);
refreshPreviewProperties();
}
示例8: RecipeButton
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public RecipeButton(final ItemEnum.Tower tower) {
super(GDefence.getInstance().assetLoader.generateImageButtonSkin(tower.getTowerTexture()));
// System.out.println(tower.getTowerTexture().getMinFilter() + " " + tower.getTowerTexture().getMagFilter());
// this.tower = tower;
towerRecipe = new Recipe(tower);
tooltip = new RecipeTooltip(towerRecipe, GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class));
tooltip.setLocked(true);
// tooltip.setVisible(false);
updateType();
addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if(type != User.RecipeType.locked && tower != ItemEnum.Tower.Basic){
if(GDefence.getInstance().user.deleteGold(towerRecipe.getGlobalCost())){
GDefence.getInstance().user.buyTowerRecipe(tower);
owner.updateTypes();//if owner != null
}
}
return true;
}
});
addListener(new TooltipListener(tooltip, true));
}
示例9: BackButton
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public BackButton(boolean ownPosition) {
super(GDefence.getInstance().assetLoader.getBackButtonSkin());
//super(mainClass.getSkin());
int backButtonsSize[] = {64, 64};
setSize(backButtonsSize[0], backButtonsSize[1]);
if(ownPosition) {
setPosition(10, Gdx.graphics.getHeight() - backButtonsSize[1]);
}
addListener(new InputListener(){
public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
//mainClass.setScreen(new MainMenu(mainClass));
GDefence.getInstance().setPreviousScreen();
return true;
}
});
}
示例10: load
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
private void load(){
tooltip = new LevelTooltip(this, GDefence.getInstance().assetLoader.get("skins/uiskin.json", Skin.class));
tooltip.setTouchable(Touchable.disabled);
//CampainMap.getStage().addActor(tooltip);
// GDefence.getInstance().getCampainMap().getStage().addActor(tooltip);
addListener(new TooltipListener(tooltip, true));
addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (!isLocked()) {
GDefence.getInstance().getLevelPreparationScreen().setLevel(number);
GDefence.getInstance().switchScreen(GDefence.getInstance().getLevelPreparationScreen());
}
return true;
}
});
}
示例11: start
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
@Override public final void start(final Callback callback) {
final Actor target = getTargetActor();
stage = target.getStage();
if (stage == null)
throw new IllegalStateException("actor not on stage!");
listener = new InputListener() {
@Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (!event.getTarget().isDescendantOf(target)) {
event.cancel();
return false;
}
return true;
}
};
stage.addCaptureListener(listener);
resources.put("allowTouchDownTo", listener);
callback.taskEnded();
}
示例12: start
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
@Override public void start(Callback callback) {
Stage stage = resources.get("stage");
InputListener listener = new InputListener() {
@Override public boolean keyUp(InputEvent event, int keycode) {
if (keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) {
event.cancel();
return true;
}
return super.keyDown(event, keycode);
}
};
stage.addCaptureListener(listener);
resources.put("restrictBackButton", listener);
callback.taskEnded();
}
示例13: DialoguePanel
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public DialoguePanel(DialoguePanelStyle style) {
super(style);
this.style = style;
pcTalkTable = new Table();
addListener(new InputListener() {
@Override
public boolean keyUp(InputEvent event, int keycode) {
int numberPressed = KeyBindings.getNumberPressed(keycode);
if (numberPressed < 1 || numberPressed > pcTalkTable.getCells().size) {
return false;
}
Actor actor = pcTalkTable.getCells().get(numberPressed-1).getActor();
pcTalkSelected(actor.getName());
return true;
}
});
}
示例14: RavUI
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
/**
* @param path - the path to the skin
*/
public RavUI (String path) {
if (!VisUI.isLoaded())
if(path.length() > 0)
VisUI.load(path);
else
VisUI.load();
screenStage = new Stage(new ScreenViewport());
debugConsole = new DebugConsole();
RavTech.input.addInputProcessor(screenStage);
screenStage.addListener(new InputListener() {
@Override
public boolean keyDown (InputEvent event, int key) {
if (key == Keys.F1)
debugConsole.toggleVisible();
return true;
}
});
screenStage.addActor(debugConsole);
}
示例15: Map
import com.badlogic.gdx.scenes.scene2d.InputListener; //导入依赖的package包/类
public Map() {
mapView = new MapView();
terrainObservers = new Array<IMapObserver>();
setX(0f);
setY(0f);
setWidth(rows * square);
setHeight(cols * square);
addListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
for (IMapObserver observer : terrainObservers) {
observer.terrainClicked((int)x, (int)y);
}
return true;
}
});
}