當前位置: 首頁>>代碼示例>>Java>>正文


Java InputListener類代碼示例

本文整理匯總了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);
}
 
開發者ID:cpppwner,項目名稱:NoRiskNoFun,代碼行數:20,代碼來源:NoRiskNoFunDrawFigures.java

示例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;
        }
    });
}
 
開發者ID:cpppwner,項目名稱:NoRiskNoFun,代碼行數:17,代碼來源:Figure.java

示例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);
}
 
開發者ID:conquest,項目名稱:conquest,代碼行數:25,代碼來源:MainMenu.java

示例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;
        }
    });
}
 
開發者ID:justinmarentette11,項目名稱:Tower-Defense-Galaxy,代碼行數:21,代碼來源:TabSelector.java

示例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);

}
 
開發者ID:DurianHLN,項目名稱:Polymorph,代碼行數:25,代碼來源:DeathScreen.java

示例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;
		}
	});
}
 
開發者ID:omar6597,項目名稱:alquran-alkarem,代碼行數:18,代碼來源:book.java

示例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();
}
 
開發者ID:raeleus,項目名稱:skin-composer,代碼行數:17,代碼來源:RootTable.java

示例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));
    }
 
開發者ID:mrDarkHouse,項目名稱:GDefence,代碼行數:24,代碼來源:RecipeButton.java

示例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;
        }
    });

}
 
開發者ID:mrDarkHouse,項目名稱:GDefence,代碼行數:19,代碼來源:BackButton.java

示例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;
            }
        });



    }
 
開發者ID:mrDarkHouse,項目名稱:GDefence,代碼行數:22,代碼來源:LevelButton.java

示例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();
}
 
開發者ID:ratrecommends,項目名稱:dice-heroes,代碼行數:19,代碼來源:AllowTouchDownToActor.java

示例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();
}
 
開發者ID:ratrecommends,項目名稱:dice-heroes,代碼行數:17,代碼來源:RestrictBackButton.java

示例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;
		}
	});
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:18,代碼來源:DialoguePanel.java

示例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);
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:23,代碼來源:RavUI.java

示例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;
        }
    });
}
 
開發者ID:aboglioli,項目名稱:libgdx-pathfinding-example,代碼行數:21,代碼來源:Map.java


注:本文中的com.badlogic.gdx.scenes.scene2d.InputListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。