本文整理匯總了Java中com.badlogic.gdx.scenes.scene2d.utils.ClickListener類的典型用法代碼示例。如果您正苦於以下問題:Java ClickListener類的具體用法?Java ClickListener怎麽用?Java ClickListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ClickListener類屬於com.badlogic.gdx.scenes.scene2d.utils包,在下文中一共展示了ClickListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ObjectEditor
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
public ObjectEditor(Scene scene, String objectName) {
this.scene = scene;
top = new Table();
top.add(new VisLabel(objectName)).expandX().pad(0, 20, 0, 20);
VisTextButton deleteObject = new VisTextButton("Delete");
deleteObject.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
hasDeleteBeenPressed = true;
delete();
}
});
top.add(deleteObject).pad(0, 20, 0, 20);
add(top).padTop(80).colspan(4).row();
bottom = new Table();
}
示例2: initialize
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
@Override
protected void initialize() {
Table topButtonBar = new Table();
topButtonBar.setFillParent(true);
VisTextButton showEditorButton = new VisTextButton("Show Editor");
showEditorButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
showEditorClicked();
}
});
topButtonBar.top().left().add(showEditorButton).pad(7);
Table bottomButtonBar = new Table();
bottomButtonBar.setFillParent(true);
stage.addActor(topButtonBar);
}
示例3: setupRedDiceOption
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private Table setupRedDiceOption(int diceNumber) {
Table redDiceOption = new Table();
redDiceOption.setBackground(redBackground);
redDiceOption.add(new Label("" + diceNumber, CatanGame.skin));
redDiceOption.setTouchable(Touchable.enabled);
redDiceOption.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (chosenRedDice == diceNumber) {
System.out.println("discard choice of " + diceNumber);
chosenRedDice = 0;
enableAllTouchablesRed();
} else {
System.out.println("choose " + diceNumber);
chosenRedDice = diceNumber;
disableAllTouchablesRed();
redDiceOption.setTouchable(Touchable.enabled);
redDiceOption.setBackground(redBackground);
}
}
});
return redDiceOption;
}
示例4: setupYellowDiceOption
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private Table setupYellowDiceOption(int diceNumber) {
Table yellowDiceOption = new Table();
yellowDiceOption.setBackground(yellowBackground);
yellowDiceOption.add(new Label("" + diceNumber, CatanGame.skin));
yellowDiceOption.setTouchable(Touchable.enabled);
yellowDiceOption.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if (chosenYellowDice == diceNumber) {
System.out.println("discard choice of " + diceNumber);
chosenYellowDice = 0;
enableAllTouchablesYellow();
} else {
System.out.println("choose " + diceNumber);
chosenYellowDice = diceNumber;
disableAllTouchablesYellow();
yellowDiceOption.setTouchable(Touchable.enabled);
yellowDiceOption.setBackground(yellowBackground);
}
}
});
return yellowDiceOption;
}
示例5: createSkins
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* Function used to create the Skins' Buttons and Labels and associate them to a given table, organized.
* It also adds Listeners to the Skins' Buttons.
*
* @param table Table where the Skins' Labels and Buttons will be organized.
*/
private void createSkins(Table table) {
for (int i = 0; i < game.getNumSkins(); ++i) {
//Adding Buttons and Labels to the Arrays
skinButtons.add(new Button(new TextureRegionDrawable(new TextureRegion(game.getAssetManager().get("big_skins/skin" + (i < 10 ? "0" : "") + i + ".png", Texture.class)))));
skinLabels.add(new Label("Current", skin1));
final int j = i; //Needed for Listener initialization
skinButtons.get(i).addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
setCurrentLabel(j);
}
});
table.add(skinButtons.get(i)).size(BUTTON_SIZE, BUTTON_SIZE).pad(IMAGE_EDGE);
}
table.row();
for (int i = 0; i < game.getNumSkins(); ++i)
table.add(skinLabels.get(i));
initializeCurrentSkin();
}
示例6: initHUD
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* Function used to initialize all the elements of the HUD and add the respective Listeners.
*/
private void initHUD() {
Table hudTable = new Table();
hudTable.setFillParent(true);
Button pauseButton = new Button(new TextureRegionDrawable(
new TextureRegion(game.getAssetManager().get("pause.png", Texture.class))));
scoreText = new Label("0:00", skin);
scoreText.setFontScale(FONT_SCALE, FONT_SCALE);
pauseButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
model.togglePause();
}
});
hudTable.top();
hudTable.add(scoreText).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).expandX()
.left().fill().padLeft(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
hudTable.add(pauseButton).size(HUD_ELEMENTS_SIZE, HUD_ELEMENTS_SIZE).fill()
.padRight(HORIZONTAL_PAD).padTop(VERTICAL_PAD);
this.addActor(hudTable);
}
示例7: createAchievementButton
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* Adds the Achievements Button to the Networking Menu.
*
* @param table The table to where the Achievements button will be added.
*/
private void createAchievementButton(Table table) {
TextButton achievementsButton = new TextButton("Achievements", skin1);
achievementsButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
gameServices.showAchievements();
}
});
table.add(achievementsButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row();
}
示例8: createSignInBtn
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* Adds the Sign In / Sign Out Button to the Networking Menu.
*
* @param table The table to where the button will be added.
*/
private void createSignInBtn(Table table) {
final TextButton signInButton = new TextButton(
gameServices.isSignedIn() ? "Sign Out" : "Sign In!", skin1);
signInButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (gameServices.isSignedIn()) {
gameServices.signOut();
signInButton.setText("Sign In!");
} else {
gameServices.signIn();
signInButton.setText("Sign Out");
}
}
});
table.add(signInButton).size(BUTTON_WIDTH, DEFAULT_BUTTON_SIZE).pad(BUTTON_EDGE).row();
}
示例9: addBackBtn
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected TextButton addBackBtn(boolean style) {
TextButton back = new TextButton("Back", (style ? skin2 : skin1));
back.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
game.setScreen(new NetworkingMenuScreen(game));
}
});
return back;
}
示例10: initBackButton
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
/**
* Create a back button to return to the game scene
*/
private void initBackButton() {
TextButtonSceneObject backButton;
backButton = new TextButtonSceneObject(sceneData.createTextButton("Back", Assets.DICE_CHEATS_TEXT_BUTTON_DESCRIPTOR), null);
backButton.setBounds(1000, 100, 500, 100);
backButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (!canRoll) {
writeRollResult(); // write roll result only now as we're done when we press back
sceneData.sendMessageFromGui(new EvaluateDiceResultGui());
}
}
});
addSceneObject(backButton);
}
示例11: initImageButtons
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private void initImageButtons() {
if (!sceneData.isGameHost()) {
return; // player is not hosting - don't offer the player to start the game.
}
imageButtonStartGame = new ImageButtonSceneObject(sceneData.createImageButton(Assets.START_GAME_BUTTON_FILENAME), buttonPressedSound);
imageButtonStartGame.setBounds((Gdx.graphics.getWidth() / 2.0f) - 137.5f, Gdx.graphics.getHeight() / 10.0f, 275f, 240f);
imageButtonStartGame.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
sceneData.sendMessageFromGui(new StartGameClicked());
}
});
addSceneObject(imageButtonStartGame);
imageButtonStartGame.setDisabled();
}
示例12: displayScores
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
@Override
public void displayScores(List<PlayerData> data) {
table.clear();
table.row();
Label winner = new Label("Last penguin standing: " + data.get(0).displayName, uiSkin);
table.add(winner).pad(10);
for (int i = 0; i < data.size(); i++) {
int rank = i + 1;
PlayerData player = data.get(i);
table.row();
String newBest = getBestText(player);
Label l = new Label(rank + ". " + player.displayName + " " + data.get(i).totalScore + newBest, uiSkin);
table.add(l).pad(5);
}
table.row();
table.add(menuButton).pad(30);
menuButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
controller.onBack();
}
});
table.addAction(Actions.fadeIn(1));
}
示例13: addChangeFaction
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private void addChangeFaction(){
groupChangeFaction = new Group();
Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
background.setSize(Width - Width * 0.03f, Height * 0.1f);
background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.3f);
groupChangeFaction.addActor(background);
Label labelFac = new Label("Change Faction",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
labelFac.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
manager.loadAssetsChoiceFaction();
gameManager.setScreen(new ScreenCircleLoading(gameManager,new ScreenChoiceFaction(gameManager),manager.getAssetsChoiceFaction()));
}
});
groupChangeFaction.addActor(labelFac);
}
示例14: addTestCombat
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private void addTestCombat(){
groupTestCombat = new Group();
Image background = new Image(new TextureRegion(manager.getAssetsSettings().getTexture(NameFiles.extensionImgBackground)));
background.setSize(Width - Width * 0.03f, Height * 0.1f);
background.setPosition(Width / 2 - background.getWidth() / 2, Height * 0.15f);
groupChangeFaction.addActor(background);
Label labelFac = new Label("Combat Training",new Label.LabelStyle(Font.getFont((int)(Height*0.025f)),Color.WHITE));
labelFac.setPosition(background.getX()+background.getWidth()*0.05f,background.getY()+background.getHeight()/2-labelFac.getHeight()/2);
labelFac.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
manager.loadAssetsEnklaveScreen();
new GetEnklaveDetails().makeRequest(16066, manager);
gameManager.screenEnklave.setEnklave3D(new Vector2(0,0));
gameManager.setScreen(new ScreenCircleLoading(gameManager,gameManager.screenEnklave,manager.getAssertEnklaveScreen()));;
}
});
groupChangeFaction.addActor(labelFac);
}
示例15: drawtopcombat
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; //導入依賴的package包/類
private void drawtopcombat(){
groupTop = new Group();
Texture lookup = managerAssets.getAssetsCombat().getTexture(NameFiles.progressbarcircular);
lookup.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
progressBarEnergy = ProgressBarEnergy.getInstance();
Image imageLeftprofile = new Image(new TextureRegion(managerAssets.getAssetsButton().get(NameFiles.buttonBack1)));
imageLeftprofile.setSize(Gdx.graphics.getWidth() * 0.15f, Gdx.graphics.getWidth() * 0.15f);
imageLeftprofile.setPosition(imageLeftprofile.getWidth() * 0.1f, Gdx.graphics.getHeight() - imageLeftprofile.getHeight() * 1.1f);
imageLeftprofile.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y) {
if(InformationProfile.getInstance().getDateUserGame().getEnklaveCombatId() == -1)
gameManager.setScreen(gameManager.screenEnklave);
else
dialogExit("You can't out from combat!");
}
});
groupTop.addActor(imageLeftprofile);
}