Java 类com.badlogic.gdx.scenes.scene2d.Actor 实例源码

项目:gdx-controllerutils    文件:ControllerMenuStage.java   
protected boolean fireEventOnActor(Actor actor, InputEvent.Type type, int pointer, Actor related) {
    if (actor == null || !isActorFocussable(actor) || !isActorHittable(actor))
        return false;

    InputEvent event = Pools.obtain(InputEvent.class);
    event.setType(type);
    event.setStage(this);
    event.setRelatedActor(related);
    event.setPointer(pointer);
    event.setButton(-1);

    actor.fire(event);

    boolean handled = event.isHandled();
    Pools.free(event);
    return handled;
}
项目:blueirisviewer    文件:MainOptionsWnd.java   
private void AddWindowButton(final UIElement window, String buttonText, Skin skin, Table table)
{
    final TextButton btn = new TextButton(buttonText, skin);

    btn.addListener(new ChangeListener()
    {
        @Override
        public void changed(ChangeEvent event, Actor actor)
        {
            if (window.isShowing())
                window.hide();
            else
                window.show();
        }
    });

    table.add(btn);
    table.row();
}
项目:libgdx_ui_editor    文件:XmlUtils.java   
private static Class getActorType(Actor actor){
    if (actor instanceof Label){
        return Label.class;
    }else if (actor instanceof CheckBox){
        return CheckBox.class;
    }else if (actor instanceof Image){
        return Image.class;
    }else if (actor instanceof TextField){
        return TextField.class;
    }else if (actor instanceof Button){
        return Button.class;
    }else if (actor instanceof Group){
        return Group.class;
    }else {
        return Actor.class;
    }
}
项目:libgdx_ui_editor    文件:SelectGroup.java   
@Override
public void drag(InputEvent event, float x, float y, int pointer) {
    if (pointer == -1) return;
    Actor actor = event.getListenerActor();
    actor.moveBy(x - getTouchDownX(), y - getTouchDownY());
    if (getAllActor().contains(SelectGroup.this.getParent(),false)){
        return;
    }
    for (Actor child : getAllActor()){
        if (child instanceof MainWindow){
            break;
        }else {
            child.moveBy(x-getTouchDownX(),y-getTouchDownY());
        }
    }
    Actor lastActor = selection.getLastSelected();
    if (lastActor!=null){
        EditorManager.getInstance().getEventBus().post(new AttrEvent(lastActor));
        if (getParent() instanceof MainWindow){
            MainWindow mainWindow = (MainWindow) getParent();
            if (mainWindow.getEditorLister()!=null) mainWindow.getEditorLister().change();
        }
    }
}
项目:libgdx_ui_editor    文件:SelectGroup.java   
private void isInsideCub(Group group){
    for (Actor child:group.getChildren()){
        if (EditorManager.getInstance().getActorType(child).equals(Group.class)){
            isInsideCub((Group) child);
        }
        if (child instanceof SelectGroup) continue;
        Vector2 childVect2 = child.getParent().localToStageCoordinates(new Vector2(child.getX(),child.getY()));
        childRect.set(childVect2.x,childVect2.y,child.getWidth(),child.getHeight());
        if (getCullingArea().overlaps(childRect)){
            if (!selection.contains(child)){
                child.debug();
                selection.add(child);
            }
        }else if (selection.contains(child)){
            selection.remove(child);
            child.setDebug(false);
        }
    }
}
项目:libgdx_ui_editor    文件:EditorManager.java   
public Actor getActorByName(String name){
    switch (name){
        case "Group":
            return new Group();
        case "Label":
            return new NativeLabel("",getMainFont());
        case "CheckBox":
            return new VisCheckBox("");
        case "Image":
            return new Image(assetManager.get("badlogic.jpg",Texture.class));
        case "Button":
            return new VisImageButton(VisUI.getSkin().get(VisImageButton.VisImageButtonStyle.class));
        case "TextField":
            return new TextField("",VisUI.getSkin());
        default:
            return new Actor();
    }
}
项目:Cubes    文件:MenuTools.java   
public static void arrange(float x, float y, float width, float height, Direction direction, Actor... actors) {
  switch (direction) {
    case Above:
    case Below:
      height = height / actors.length;
      break;
    case Left:
    case Right:
      width = width / actors.length;
      break;
  }
  if (direction == Direction.Below) {
    y -= height;
  }
  setSize(width, height, actors);
  Actor prev = actors[0];
  setPos(x, y, prev);
  for (int i = 1; i < actors.length; i++) {
    Actor curr = actors[i];
    move(curr, direction, prev);
    prev = curr;
  }
}
项目:libgdx_ui_editor    文件:AttrGeneralWindow.java   
public void refreshAttr(Actor actor){
    if (xTextField == null){
        initGeneralAttr();
    }
    xTextField.setText(String.format("%.2f",actor.getX()));
    yTextField.setText(String.format("%.2f",actor.getY()));
    nameTextField.setText(actor.getName());
    scaleXTF.setText(String.valueOf(actor.getScaleX()));
    scaleYTF.setText(String.valueOf(actor.getScaleY()));
    orignYTextField.setText(String.format("%.2f",actor.getOriginY()));
    orignXTextField.setText(String.format("%.2f",actor.getOriginX()));
    widthText.setText(String.format("%.2f",actor.getWidth()));
    heightText.setText(String.format("%.2f",actor.getHeight()));
    rotationText.setText(String.format("%.2f",actor.getRotation()));
    colorImage.setColor(actor.getColor());
    picker.setColor(actor.getColor());
    visibleBox.setChecked(actor.isVisible());
    zIndexTF.setText(String.valueOf(actor.getZIndex()));
}
项目:libgdx_ui_editor    文件:AttrUniqueWindow.java   
public void refreshAttr(Actor actor) {
    if (uniqueTable == null) {
        uniqueTable = new VisTable(true);
        uniqueTable.left().padLeft(10f).top().padTop(20);
        VisScrollPane scrollPane = new VisScrollPane(uniqueTable);
        scrollPane.setScrollingDisabled(true,false);
        add(scrollPane).expand().fill();
    }
    uniqueTable.clearChildren();
    if (actor instanceof Label) {
        initLabelAttr((Label) actor, uniqueTable);
    } else if (actor instanceof Image) {
        initImageAttr((Image) actor, uniqueTable);
    }  else if (actor instanceof TextField){
        initTextFieldAttr((TextField) actor,uniqueTable);
    }else if (actor instanceof CheckBox){
        initCheckBoxAttr((CheckBox) actor,uniqueTable);
    }else if (actor instanceof Button) {
        initButtonAttr((Button) actor, uniqueTable);
    }

}
项目:libgdx_ui_editor    文件:AssetWindow.java   
public void build(FileItem fileItem) {
    clearChildren();
    if (fileItem == null) {
        addItem(new MenuItem("New Scene", new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {

            }
        }));
    }
}
项目:Cubes    文件:MultiplayerConnectMenu.java   
public MultiplayerConnectMenu() {
  super();
  title = new Label(Localization.get("menu.multiplayer.title"), skin.get("title", Label.LabelStyle.class));
  address = new TextField("", skin);
  address.setMessageText(Localization.get("menu.multiplayer.address"));
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.multiplayer.port", 24842)); //Not "Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)" because the port is set on the server
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  connect = new TextButton(Localization.get("menu.multiplayer.connect"), skin);
  back = MenuTools.getBackButton(this);

  connect.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new MultiplayerLoadingMenu(address.getText().isEmpty() ? "localhost" : address.getText(), port.getText().isEmpty() ? 24842 : Integer.parseInt(port.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(address);
  stage.addActor(port);
  stage.addActor(connect);
  stage.addActor(back);
}
项目:FlappySpinner    文件:MenuScreen.java   
public void setUpPlayButton() {
    playButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "playbtn", false);
    playButton.setPosition(Constants.WIDTH / 4 - playButton.getWidth() * 2 / 5,
            Constants.HEIGHT / 2 - playButton.getHeight() * 2.5f -2);
    playButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            //FlappySpinner.gameManager.hideAd();
            float delay = 0.3f;
            setUpFadeOut();
            Timer.schedule(new Timer.Task() {
                @Override
                public void run() {
                    game.setScreen(new GameScreen(game, 0, false));
                }
            }, delay);
        }
    });
    stage.addActor(playButton);
}
项目:gdx-controllerutils    文件:ControllerMenuStage.java   
/**
 * checks if the given actor is focussable: in the list of focussable actors, visible, touchable, and on the stage
 *
 * @param actor
 * @return true if focussable
 */
protected boolean isActorFocussable(Actor actor) {
    if (!focussableActors.contains(actor, true))
        return false;

    if (!actor.isVisible())
        return false;

    if (!actor.isTouchable())
        return false;

    if (actor.getStage() != this)
        return false;

    return true;
}
项目:Cubes    文件:ServerSetupMenu.java   
public ServerSetupMenu(final Save save) {
  super();
  title = new Label(Localization.get("menu.server.title"), skin.get("title", Label.LabelStyle.class));
  saveLabel = new Label(Localization.get("menu.server.save", save.name), skin);
  saveLabel.setAlignment(Align.center);
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.server.port", Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)));
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  start = new TextButton(Localization.get("menu.server.start"), skin);
  back = MenuTools.getBackButton(this);

  start.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      int p = port.getText().isEmpty() ? Settings.getIntegerSettingValue(Settings.NETWORKING_PORT) : Integer.parseInt(port.getText());
      Adapter.setMenu(new ServerRunningMenu(save, p));
    }
  });

  stage.addActor(title);
  stage.addActor(saveLabel);
  stage.addActor(port);
  stage.addActor(start);
  stage.addActor(back);
}
项目:Catan    文件:TradeOfferItem.java   
TradeOfferItem(String player, ResourceMap offer, Skin skin) {
    this.skin = skin;

    resources = new ArrayList<>(offer.size());
    counts = new ArrayList<>(offer.size());
    label = new Label(player, skin);
    accept = new TextButton("Accept", skin);
    accept.setWidth(accept.getWidth() + 40);
    accept.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (acceptListener != null) {
                acceptListener.onAcceptClicked(getOwner(), TradeOfferItem.this.offer);
            }
        }
    });

    setOffer(offer);

    if (resources.isEmpty())
        return;

    addActor(label);

    addActor(accept);
}
项目:Catan    文件:LobbyScreen.java   
/**
 * Remove a player from the list of players as a result of him/her leaving
 * the game.
 *
 * @param username username of the player
 */
private void removePlayer(String username) {
    Table playerTable = null;
    // Find the table row containing the player that left the game
    final SnapshotArray<Actor> children = playersTable.getChildren();
    // Ignore the first child since it's just the table header
    for (int i = 1; i < children.size; i++) {
        Actor actor = children.get(i);
        if (actor instanceof Table) {
            final Actor label = ((Table) actor).getCells().get(0).getActor();
            if (label instanceof Label) {
                if (((Label) label).getText().toString().equals(username)) {
                    playerTable = ((Table) actor);
                    break;
                }
            }
        }
    }
    if (playerTable != null)
        playersTable.removeActor(playerTable);
}
项目:GangsterSquirrel    文件:SettingsMenu.java   
@Override
public void changed(ChangeEvent event, Actor actor) {
    settings.setFullscreen(fullscreenCheckBox.isChecked());

    // Set resolution to maximum when switching to fullscreen
    if (settings.getGameWidth() != screenWidth && settings.getGameHeight() != screenHeight) {
        settings.setGameWidth(screenWidth);
        settings.setGameHeight(screenHeight);

        String selected = (String) resolutionSelectBox.getSelected();
        if (items.containsKey(selected)) {
            ResolutionObject selectedResolution = items.get(selected);
            changeAspectRatioOfGameForResolution(selectedResolution);
        }

        setResolutionSelectionToCurrentResolution();
    }

    game.changeGameResolution();
}
项目:gdx-controllerutils    文件:ControllerMenuStage.java   
/**
 * sets the currently focussed actor
 *
 * @param actor
 * @return
 */
public boolean setFocussedActor(Actor actor) {
    if (focussedActor == actor)
        return true;

    if (actor != null && !isActorFocussable(actor))
        return false;

    Actor oldFocussed = focussedActor;
    if (oldFocussed != null) {
        focussedActor = null;
        onFocusLost(oldFocussed, actor);
    }

    // focussedActor kann durch onFocusLost->touchCancel verändert worden sein, dann nicht neu setzen
    if (focussedActor == null) {
        focussedActor = actor;
        if (focussedActor != null)
            onFocusGained(focussedActor, oldFocussed);
    }

    return true;
}
项目:drc-sim-client    文件:StageConfigKeyboard.java   
@Override
void addItems() {
    getList().clearItems();
    config.load();
    for (final String item[] : buttonItems) {
        if (item[1].contains("JOYSTICK")) // Not implemented
            continue;
        addItem(String.format("%s - [%s]", item[0],
                StageConfigInput.getInputDisplayName(StageConfigInput.KEYBOARD, config, item[1])),
                new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                Client.setStage(new StageConfigInput(StageConfigInput.KEYBOARD, config, item[1], item[0]));
            }
        });
    }
    // Back
    addStageChangeItem("Back", StageSettings.class);
}
项目:GDX-Engine    文件:UIManager.java   
public void setMenuVisible(boolean visible){
    if(visible)
        //always make main menu on top when it's visible
        mainMenu.setZIndex(100);

    for(Actor actor : getActors()){
        if(actor != mainMenu){
            if(visible)
                actor.setTouchable(Touchable.disabled);
            else
                actor.setTouchable(Touchable.enabled);
        }
        else
        {
            mainMenu.setVisible(visible);
            mainMenu.setTouchable(Touchable.enabled);
            //make the windows in screen center
            float windowX = (Gdx.graphics.getWidth() - mainMenu.getWidth())/2f;
            float windowY = (Gdx.graphics.getHeight() - mainMenu.getHeight())/2f;
            mainMenu.setPosition(windowX, windowY);
        }
    }
}
项目:GDX-Engine    文件:GameDialog.java   
public GameDialog(Skin skin) {
super("", skin);

waveLevel = new Label("", skin);
monsHP = new Label("", skin);
monsBonus = new Label("", skin);
monsSpeed = new Label("", skin);
monsNumber = new Label("", skin);
btnOK = new TextButton("Okay, Let them come!", skin);
btnOK.addListener(new ChangeListener() {

    @Override
    public void changed(ChangeEvent event, Actor actor) {
    // TODO Auto-generated method stub
    setVisible(false);

    }
});
setTitle(" There are more monsters are coming to you... ");
   }
项目:Cubes_2    文件:SingleplayerSaveDeleteMenu.java   
public SingleplayerSaveDeleteMenu(final Save save) {
    title = new Label(Localization.get("menu.singleplayer.delete.title"),
            skin.get("title", Label.LabelStyle.class));
    text = new Label(Localization.get("menu.singleplayer.delete.text", save.name), skin);
    delete = new TextButton(Localization.get("menu.singleplayer.delete.delete", save.name), skin);
    back = MenuTools.getBackButton(this);

    text.setAlignment(Align.center);

    delete.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            ClientSaveManager.deleteSave(save);
            Menu prev = MenuManager.getPrevious(SingleplayerSaveDeleteMenu.this);
            if (!(prev instanceof SingleplayerSavesMenu))
                return;
            ((SingleplayerSavesMenu) prev).updateSavesList();
            Adapter.setMenu(prev);
        }
    });

    stage.addActor(title);
    stage.addActor(text);
    stage.addActor(delete);
    stage.addActor(back);
}
项目:FlappySpinner    文件:MarketScreen.java   
public void setUpNextButton() {
    nextButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "playbtn", false);
    nextButton.setPosition(Constants.WIDTH * 3 / 4 - nextButton.getWidth() * 3 / 5,
            Constants.HEIGHT / 2 - nextButton.getHeight() * 3.5f);
    nextButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (position == Constants.SKIN_COUNT - 1) {
                position = 0;
            } else {
                position++;
            }
            changeShownSkin();
        }
    });
    stage.addActor(nextButton);
}
项目:Cubes_2    文件:MultiplayerConnectMenu.java   
public MultiplayerConnectMenu() {
  super();
  title = new Label(Localization.get("menu.multiplayer.title"), skin.get("title", Label.LabelStyle.class));
  address = new TextField("", skin);
  address.setMessageText(Localization.get("menu.multiplayer.address"));
  port = new TextField("", skin);
  port.setMessageText(Localization.get("menu.multiplayer.port", 24842)); //Not "Settings.getIntegerSettingValue(Settings.NETWORKING_PORT)" because the port is set on the server
  port.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
  connect = new TextButton(Localization.get("menu.multiplayer.connect"), skin);
  back = MenuTools.getBackButton(this);

  connect.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
      Adapter.setMenu(new MultiplayerLoadingMenu(address.getText().isEmpty() ? "localhost" : address.getText(), port.getText().isEmpty() ? 24842 : Integer.parseInt(port.getText())));
    }
  });

  stage.addActor(title);
  stage.addActor(address);
  stage.addActor(port);
  stage.addActor(connect);
  stage.addActor(back);
}
项目:libgdx_ui_editor    文件:XmlUtils.java   
private static void parseGenAttr(Actor actor, XmlReader.Element element){
    actor.setWidth(element.getFloat("width",100));
    actor.setHeight(element.getFloat("height",100));
    actor.setPosition(element.getFloat("x",0),element.getFloat("y",0));
    actor.setOrigin(element.getFloat("originX",0),element.getFloat("originY",0));
    if (element.getAttributes().containsKey("name")){
        actor.setName(element.get("name"));
    }
}
项目:FlappySpinner    文件:MenuScreen.java   
public void setUpSettingsButton() {
    settingsButton = new GameButton(Constants.SQUARE_BUTTON_SIZE - 0.4f, Constants.SQUARE_BUTTON_SIZE - 0.4f, "settings", false);
    settingsButton.setPosition(1, Constants.HEIGHT / 2 - settingsButton.getHeight() - 1);
    settingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(new SettingsScreen(game));
        }
    });
    stage.addActor(settingsButton);
}
项目:libgdx_ui_editor    文件:SelectGroup.java   
public SelectGroup(){
    cubRect = new Rectangle();
    childRect = new Rectangle();
    setCullingArea(cubRect);
    cubDra = DrawableUtil.getRectLineDrawable("icon/select.9.png");
    selection = new Selection<Actor>();
    addListener(dragListener);
}
项目:FlappySpinner    文件:SettingsScreen.java   
public void setUpGitHubButton() {
    githubButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "github", false);
    githubButton.setPosition(Constants.WIDTH - githubButton.getWidth() - 1, 1);
    githubButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Gdx.net.openURI("https://github.com/ZephyrVentum");
        }
    });
    stage.addActor(githubButton);
}
项目:libgdx_ui_editor    文件:FileUtils.java   
public static void readAttr(Group parentGroup, XmlReader.Element element, EventListener dragListener){
    if (element.getName().equals("Stage")){
        XmlUtils.parseGenAttr(parentGroup,element);
        if (element.getChildCount()>0){
            for (int i = 0;i<element.getChildCount();i++){
                readAttr(parentGroup,element.getChild(i),dragListener);
            }
        }
    }else if (element.getName().equals("Group")){
        Group group = new Group();
        XmlUtils.parseGenAttr(group,element);
        group.addListener(dragListener);
        parentGroup.addActor(group);
       if (element.getChildCount()>0){
           for (int i = 0;i<element.getChildCount();i++){
               readAttr(group,element.getChild(i),dragListener);
           }
       }
    }else {
        Actor actor = EditorManager.getInstance().getActorByName(element.getName());
        parentGroup.addActor(actor);
        actor.addListener(dragListener);
        XmlUtils.parseGenAttr(actor,element);
        XmlUtils.parseUqAttr(actor,element);
    }

}
项目:libgdx_ui_editor    文件:FileUtils.java   
public static void writeUqAttr(XmlWriter xmlWriter,Actor actor) throws IOException {
    Object userobject = actor.getUserObject();
    if (userobject!=null&&userobject instanceof HashMap){
        HashMap<String,String> attrMap = (HashMap<String,String>)userobject;
        for (String key : attrMap.keySet()){
            xmlWriter.attribute(key,attrMap.get(key));
        }
    }
}
项目:libgdx_ui_editor    文件:XmlUtils.java   
public static void parseGenAttr(Actor actor, XmlReader.Element element){
    actor.setWidth(element.getFloat("width",100));
    actor.setHeight(element.getFloat("height",100));
    actor.setPosition(element.getFloat("x",0),element.getFloat("y",0));
    actor.setOrigin(element.getFloat("originX",0),element.getFloat("originY",0));
    if (element.getAttributes().containsKey("name")){
        actor.setName(element.get("name"));
    }
}
项目:libgdx_ui_editor    文件:XmlUtils.java   
public static void parseUqAttr(Actor actor, XmlReader.Element element){
    Class cls  = EditorManager.getInstance().getActorType(actor);
    if (cls.equals(Label.class)){
        parseLabel((Label) actor,element);
    }else if (cls.equals(Image.class)){
        parseImage((Image) actor,element);
    }else if (cls.equals(Button.class)){
        parseButton((VisImageButton) actor,element);
    }else if (cls.equals(TextField.class)){
        parseTextField((TextField) actor,element);
    }
}
项目:libgdx_ui_editor    文件:XmlUtils.java   
private static HashMap getActorAttr(Actor actor){
    if (actor.getUserObject() !=null && actor.getUserObject() instanceof HashMap){
        return (HashMap) actor.getUserObject();
    }else {
       return new HashMap<>();
    }
}
项目:Cubes_2    文件:BooleanSetting.java   
@Override
public Actor getActor(VisualSettingManager visualSettingManager) {
  final TextButton textButton = new TextButton(b ? "True" : "False", visualSettingManager.getSkin());
  textButton.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {//easier than SettingsMenu.SaveEvent and works
      set(!get());
      textButton.setText(b ? "True" : "False");
    }
  });
  return textButton;
}
项目:Catan    文件:SessionScreen.java   
private void setupPlayProgressCardButton(TextButton playButton, String buttonText, ProgressCardType type) {
    playButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if(!aSessionController.controlPlayProgressCard(aSessionController.getPlayerColor())) {
                addGameMessage("Some comment about progress card play");
            }
            aSessionController.getProgressCardHandler().handle(type, aSessionController.getPlayerColor());
            System.out.println(type.toString().toLowerCase()+" card played");
        }
    });
}
项目:Catan    文件:CatanWindow.java   
private void init() {
    // Make the window around 3/4 of the screen
    setSize(width, height);

    // Position window in the middle
    setPosition(Gdx.graphics.getWidth() / 2 - getWidth() / 2, Gdx.graphics.getHeight() / 2 - getHeight() / 2);

    // Center title
    getTitleLabel().setAlignment(Align.center);

    // Create the close button
    if (getTitleLabel().getText().length != 0) {
        closeButton = new TextButton("X", getSkin());
        closeButton.setSize(20, 20);
        closeButton.addListener(new ChangeListener() {
            @Override
            public void changed(ChangeEvent event, Actor actor) {
                closeButton.setChecked(false);
                close();
            }
        });
        getTitleTable().addActor(closeButton);
        closeButton.setPosition(getWidth() - closeButton.getWidth() - 5, 0);
    }

    getTitleTable().getCells().get(0).expandY().fillY();

    setMovable(false);
    setModal(true);

    row();
}
项目:Catan    文件:FishTradeWindow.java   
private void initButton(Button b, int choiceNumber) {
    b.setColor(Color.BLUE);
    b.pad(5);
    b.pack();
    b.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            choice = choiceNumber;
            ableall();
            b.setDisabled(true);
        }
    });
}
项目:FlappySpinner    文件:GameScreen.java   
public void setUpHomeButton() {
    homeButton = new GameButton(Constants.SQUARE_BUTTON_SIZE - 0.4f, Constants.SQUARE_BUTTON_SIZE - 0.4f, "home", false);
    homeButton.setPosition(1, Constants.HEIGHT - homeButton.getHeight() - 1);
    homeButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            aGame.setScreen(new MenuScreen(aGame));
        }
    });
    homeButton.setVisible(false);
    stage.addActor(homeButton);
}
项目:NoRiskNoFun    文件:ImageButtonSceneObjectTests.java   
@Before
public void setUp() {

    Actor mockActor = mock(Actor.class);
    mockAssetImageButton = mock(AssetImageButton.class);
    doReturn(mockActor).when(mockAssetImageButton).getActor();
}
项目:Cubes    文件:MenuTools.java   
public static void arrangeX(float y, boolean centerY, Actor... actors) {
  float w = GUI_WIDTH / actors.length;
  for (int i = 0; i < actors.length; i++) {
    Actor a = actors[i];
    a.setPosition(((i + 0.5f) * w) - (a.getWidth() / 2f), y - (centerY ? (a.getWidth() / 2f) : 0));
  }
}