Java Code Examples for com.badlogic.gdx.scenes.scene2d.Stage

The following are top voted examples for showing how to use com.badlogic.gdx.scenes.scene2d.Stage. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Race99   File: StageFactory.java   Source Code and License 7 votes vote down vote up
public Stage createLoadingStage(){
    Stage stage = createStage();
    stage.setViewport(viewport);
    stage.addActor(new GameObjectBodyless(new Texture("default_background.png")));
    GameObjectBodyless gameObjectBodyless = new GameObjectBodyless(new Texture("loading_screen_part1.png")){
        @Override
        public void act(float delta) {
            super.act(delta);
            getSprite().setOriginCenter();
            getSprite().rotate(3);
        }
    };
    gameObjectBodyless.setPosition(viewport.getScreenWidth() - gameObjectBodyless.getSprite().getWidth(),
            viewport.getScreenHeight() - gameObjectBodyless.getSprite().getHeight());
    stage.addActor(gameObjectBodyless);
    return stage;
}
 
Example 2
Project: DarkDay   File: Hud.java   Source Code and License 6 votes vote down vote up
public Hud(SpriteBatch sb) {
    countKill = 0;
    viewport = new FitViewport(ScreenConf.V_WIDTH, ScreenConf.V_HEIGHT, new OrthographicCamera());

    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.setFillParent(true);
    table.top();

    countKillLabel = new Label(String.format("%03d", countKill), new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(countKillLabel).expandX().padTop(10);
    table.add().expandX();
    table.add().expandX();
    table.add().expandX();
    stage.addActor(table);

}
 
Example 3
Project: Catan   File: KnightActor.java   Source Code and License 6 votes vote down vote up
public KnightActionsWindow displayActions(Stage stage) {
    if (stage != null) {
        // Create the window if it's not created
        if (actionWindow == null)
            actionWindow = new KnightActionsWindow(this);

        actionWindow.setPosition(getX() + getWidth(), getTop());

        // Add the window if not already added
        if (!actionWindow.hasParent())
            stage.addActor(actionWindow);

        return actionWindow;
    }
    return null;
}
 
Example 4
Project: feup-lpoo-armadillo   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Menu Screen's constructor.
 * It initializes all the Menu elements.
 *
 * @param game The current game session.
 */
protected MenuScreen(final Armadillo game) {
    this.game = game;
    batch = game.getBatch();
    gameServices = game.getGameServices();
    skin1 = game.getPrimarySkin();
    skin2 = game.getSecondarySkin();

    viewport = new FitViewport(VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
    viewport.apply();

    stage = new Stage(viewport, batch);

    backgroundImg = new Image(game.getAssetManager().get("background.png", Texture.class));
    backgroundImg.setScale(VIEWPORT_WIDTH / backgroundImg.getWidth(), VIEWPORT_HEIGHT / backgroundImg.getHeight());

    titleImg = new Image(game.getAssetManager().get("armadillo_title.png", Texture.class));
    titleImg.setSize(0.8f * titleImg.getWidth(), 0.8f * titleImg.getHeight());
    titleImg.setPosition(VIEWPORT_WIDTH / 2 - titleImg.getWidth() / 2, VIEWPORT_HEIGHT * 0.98f - titleImg.getHeight());
}
 
Example 5
Project: NoRiskNoFun   File: NoRiskNoFunDrawFigures.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 6
Project: Cubes   File: CraftingInventoryActor.java   Source Code and License 6 votes vote down vote up
@Override
protected void setStage(Stage stage) {
  if (stage == null) {
    for (int i = 0; i < 9; i++) {
      if (c.itemStacks[i] != null)
        InventoryHelper.addItemstack(Cubes.getClient().player.getInventory(), c.itemStacks[i]);
    }
  }
  super.setStage(stage);
}
 
Example 7
Project: conquest   File: MainMenu.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 8
Project: projecttd   File: HudScene.java   Source Code and License 6 votes vote down vote up
public HudScene(SpriteBatch batch, ShapeRenderer shapeRenderer, ArcRenderer arcRenderer) {
    this.batch = batch;
    stage = new Stage();

    VisUI.load();

    Table table = new Table();
    table.top();
    table.setFillParent(true);

    scoreLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setScore(score);
    balanceLabel = new Label("", new Label.LabelStyle(new BitmapFont(), Color.VIOLET));
    setBalance(balance);

    table.add(scoreLabel).align(Align.left).expandX();
    table.add(balanceLabel).align(Align.right).expandX();

    stage.addActor(table);


    ringButton = new RingButton(shapeRenderer, arcRenderer);
    ringButton.setBounds(10, 10, 100, 100);
    stage.addActor(ringButton);
}
 
Example 9
Project: bobbybird   File: LoadingState.java   Source Code and License 6 votes vote down vote up
@Override
public void start() {
    finishedLoading = false;
    
    stage = new Stage(new ScreenViewport());
    
    skin = createSkin();
    
    Image image= new Image(skin, "bg");
    image.setScaling(Scaling.stretch);
    image.setFillParent(true);
    stage.addActor(image);
    
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);
    
    progressBar = new ProgressBar(0, 1, .01f, false, skin);
    progressBar.setAnimateDuration(.1f);
    root.add(progressBar).growX().expandY().pad(20.0f);
}
 
Example 10
Project: FlappySpinner   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
public MenuScreen(Game game) {
    Box2D.init();
    this.game = game;
    world = new World(new Vector2(0, 0), false);
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();
    Gdx.input.setInputProcessor(stage);

    FlappySpinner.gameManager.changeBackgroundColor("#4ec0ca");

    setUpBackground();
    setUpButtons();
    setUpLogo();
}
 
Example 11
Project: summer17-android   File: MenuState.java   Source Code and License 6 votes vote down vote up
public void create() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    //font = new BitmapFont();
    //skin = new Skin();
    //buttonAtlas = new TextureAtlas(Gdx.files.internal());
    //skin.addRegions(buttonAtlas);

    button = new Button();
    button.setStyle(new Button.ButtonStyle());

    button.addCaptureListener(new EventListener() {
        @Override
        public boolean handle(Event event) {
            Gdx.app.log("LOG", "event " + event);
            return false;
        }
    });
    stage.addActor(button);
}
 
Example 12
Project: arcadelegends-gg   File: InputSettingsScreen.java   Source Code and License 6 votes vote down vote up
/**
 * Method responsible for initializing the main menu
 * Called when the screen becomes the current screen of the game
 */
@Override
public void show() {
    cam = new OrthographicCamera();
    viewport = new FitViewport(1920, 1080);
    viewport.setCamera(cam);
    stage = new Stage(viewport);
    stage.setViewport(viewport);
    skin = settingsAssets.styles_json;
    int x = 1920;
    int y = 1080;
    spriteBatch = new SpriteBatch();
    mainbackground = settingsAssets.testmainscreen;
    BitmapFont font = settingsAssets.bocklin_fnt;
    TextureRegion backgroundTexture = new TextureRegion(settingsAssets.background_textbutton);

    inputTable = new Table();
    keys = IInputConfig.InputKeys.values();
    keyMap = new HashMap<>();

    initInputRows(font, backgroundTexture);
    createBackButton();
    AL.input.setInputProcessor(new InputMultiplexer(stage, this));
}
 
Example 13
Project: enklave   File: ScreenExtensions.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    if(drawone){
        addBackgroundExtension();
        addPuls();
        addimagebg();
        addButtonBottom();
        drawone = false;
    }
    cameraGroupStrategy = new CameraGroupStrategy(camera);
    batch = new DecalBatch(cameraGroupStrategy);
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    addtostage();
    Gdx.input.setCatchBackKey(true);
    inputmulti = new InputMultiplexer();
    inputmulti.addProcessor(stage);
    Gdx.input.setInputProcessor(inputmulti);
}
 
Example 14
Project: enklave   File: ScreenRooms.java   Source Code and License 6 votes vote down vote up
@Override
    public void show() {
        if(drawone){
            addroomselect();
            addButtonBottom();
            addPuls();
            addimagebg();
            addbuildRoom();
            addtimerbuildroom();
            drawone = false;
        }
        cameraGroupStrategy = new CameraGroupStrategy(camera);
//        CameraInputController controller = new CameraInputController(camera);
        stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
        batchsprite = new SpriteBatch();
        addtostage();
        batch = new DecalBatch(this.cameraGroupStrategy);
        Gdx.input.setCatchBackKey(true);
        InputMultiplexer inputmulti = new InputMultiplexer();
        inputmulti.addProcessor(stage);
        Gdx.input.setInputProcessor(inputmulti);
    }
 
Example 15
Project: enklave   File: ScreenDescribeEnklave.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    if(drawone){
        addActiveRooms();
        createBuildRoom();
        createAddExtensionGroup();
        addDescribeEnklave();
        drawone = false;
    }
    backButton.setChecked(false);
    Gdx.input.setCatchBackKey(true);
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    addtoStage(stage);
    stage.addActor(backButton);
    Gdx.input.setInputProcessor(stage);
}
 
Example 16
Project: enklave   File: ScreenSetting.java   Source Code and License 6 votes vote down vote up
@Override
public void show() {
    stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
    if(drawone) {
        initializeMenuTab();
        manager.loadAssetsSettings();
        manager.getAssetsSettings().finish();
        addSettingTutorial();
        addSettingPresentation();
        addChangeFaction();
        addKeepScreenOn();
        addTestCombat();
        drawone = false;
    }
    addtoStage();
    checkButtons();
    b5.setChecked(true);
    sp.setScrollPercentX(100);
    sp.updateVisualScroll();
    backButton.setChecked(false);
    Gdx.input.setCatchBackKey(true);
    Gdx.input.setInputProcessor(stage);
}
 
Example 17
Project: gdx-controllerutils   File: ControllerMenuDialog.java   Source Code and License 6 votes vote down vote up
@Override
public Dialog show(Stage stage, Action action) {
    previousFocussedActor = null;
    previousEscapeActor = null;

    super.show(stage, action);

    if (stage instanceof ControllerMenuStage) {
        previousFocussedActor = ((ControllerMenuStage) stage).getFocussedActor();
        previousEscapeActor = ((ControllerMenuStage) stage).getEscapeActor();

        if (buttonsToAdd.size >= 1)
            ((ControllerMenuStage) stage).setFocussedActor(buttonsToAdd.get(0));

        if (buttonsToAdd.size == 1)
            ((ControllerMenuStage) stage).setEscapeActor(buttonsToAdd.get(0));
    }

    return this;

}
 
Example 18
Project: Polymorph   File: GameScreen.java   Source Code and License 6 votes vote down vote up
private void initHud() {
    hud = new Stage(viewport, batch);
    Gdx.input.setInputProcessor(new InputMultiplexer(new KeyboardInputHandler(), hud));

    //init widgets
    ColorButton[] colorButtons = createColorButtons();
    final ShapeButton[] shapeButtons = createShapeButtons(colorButtons);

    // add widgets to stage
    for (ShapeButton shapeButton : shapeButtons) {
        hud.addActor(shapeButton);
    }
    for (ColorButton colorButton : colorButtons) {
        hud.addActor(colorButton);
    }

    TextureAtlas textureAtlas = polymorph.getAssetManager().get(Polymorph.MASTER_PATH, TextureAtlas.class);
    hud.addActor(createHealthBar(textureAtlas));
    hud.addActor(createPauseButton(textureAtlas));
}
 
Example 19
Project: MMORPG_Prototype   File: QuestBoardDialog.java   Source Code and License 6 votes vote down vote up
public QuestBoardDialog(ActorManipulator linkedContainer, long id, QuestDataPacket[] quests,
		Stage containerForPopUpDialog, PacketsSender packetsSender)
{
	super("Quests", linkedContainer, id);

	for(QuestDataPacket quest : quests)
	{
	    QuestPosition questPosition = new QuestPosition(quest.getName(), quest.getDescription(), containerForPopUpDialog, packetsSender);
	    questPositions.put(quest.getName(), questPosition);
	    getContentTable().add(questPosition);
	    getContentTable().row();
	}
	if(questPositions.isEmpty())
           addNoQuestsAvailableLabel();

	this.pack();
}
 
Example 20
Project: GangsterSquirrel   File: MenuScreen.java   Source Code and License 6 votes vote down vote up
public MenuScreen(MainGameClass game) {
    this.game = game;

    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    skin = new Skin(Gdx.files.internal("skins/Flat_Earth_UI_Skin/flatearthui/flat-earth-ui.json"));

    progressBarStyle = skin.get("fancy", ProgressBar.ProgressBarStyle.class);
    TiledDrawable tiledDrawable = skin.getTiledDrawable("slider-fancy-knob").tint(skin.getColor("selection"));
    tiledDrawable.setMinWidth(0);
    progressBarStyle.knobBefore = tiledDrawable;

    sliderStyle = skin.get("fancy", Slider.SliderStyle.class);
    sliderStyle.knobBefore = tiledDrawable;

    layoutTable = new Table();
    layoutTable.top();
    layoutTable.setFillParent(true);
    layoutTable.pad(getPixelSizeFromDensityIndependentPixels(50));
}
 
Example 21
Project: ProjektGG   File: BaseUIScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
	stage = new Stage(new ScreenViewport());
	mainTable = new Table();
	stage.addActor(mainTable);
	mainTable.setFillParent(true);

	mainTable.setDebug((boolean) game.showDebugStuff());

	game.setInputProcessor(stage);

	initUI();
}
 
Example 22
Project: cocos2d-java   File: GdxUIConsole.java   Source Code and License 5 votes vote down vote up
@Override
protected boolean onUpdate(float dt) {
	Stage stage = input.getStage();
	if(stage != null) {
		stage.setKeyboardFocus(input);
	}
	flushOutput();
	return true;
}
 
Example 23
Project: bobbybird   File: MenuState.java   Source Code and License 5 votes vote down vote up
@Override
public void start() {
    skin = getCore().getAssetManager().get(Core.DATA_PATH + "/skin/skin.json", Skin.class);
    stage = new Stage(new ScreenViewport());
    
    Gdx.input.setInputProcessor(stage);
    
    Image bg = new Image(skin, "sky");
    bg.setFillParent(true);
    stage.addActor(bg);
    
    createBG();
    
    createMenu();
}
 
Example 24
Project: libgdx_ui_editor   File: MainPanel.java   Source Code and License 5 votes vote down vote up
public void setListeners(Stage stage) {
    stage.addListener(new InputListener() {
        @Override
        public boolean scrolled(InputEvent event, float x, float y, int amount) {
            if (editingZone != null) editingZone.zoomBy(amount);
            return false;
        }
    });
}
 
Example 25
Project: Race99   File: StageFactory.java   Source Code and License 5 votes vote down vote up
public Stage createStartStage(){
    Stage stage = createStage();
    stage.setViewport(viewport);
    stage.addActor(new GameObjectBodyless(new Texture("splash_screen1.png")){

        private int i = 100;
        private int counter = 0;

        @Override
        public void act(float delta) {
            super.act(delta);
            if (i < 0){
                i = 100;
                counter++;
                if (counter == 2){
                    remove();
                    setChanged();
                    notifyObservers("StartStageEnd");
                }
                setTexture(new Texture("splash_screen2.png"));
                setSprite(new Sprite(getTexture()));
            } else if (i >= 0) {
                i--;
            }
        }
    });
    return stage;
}
 
Example 26
Project: gdx-splash   File: LockWindow.java   Source Code and License 5 votes vote down vote up
private void setupUI() {
    stage = new Stage();
    VisTable root = new VisTable();
    stage.addActor(root);
    root.setFillParent(true);
    root.align(Align.center);

    VisLabel label = new VisLabel("It appears you have already opened an instance of this app.\n\n" +
            "To ensure data integrity this is not possible. If you are sure that no open app " +
            "instance exists delete the lock file ~/.gdxsplash/.lock and restart GdxSplash.");
    label.setAlignment(Align.center);
    label.setWrap(true);
    root.add(label).pad(10).grow().row();
}
 
Example 27
Project: FlappySpinner   File: GameScreen.java   Source Code and License 5 votes vote down vote up
public GameScreen(Game game, int score, boolean isRelife) {
    Box2D.init();

    SCORE = score;
    this.isRelife = isRelife;

    preferences = new GamePreferences();
    audioManager = AudioManager.getInstance();

    aGame = game;
    stage = new Stage(new StretchViewport(Constants.WIDTH, Constants.HEIGHT));
    world = WorldUtils.createWorld();
    world.setContactListener(this);

    FlappySpinner.gameManager.changeBackgroundColor("#e9fcd9");

    Gdx.input.setInputProcessor(stage);

    state = GameState.RESUME;

    setUpBackground();
    setUpTube();
    setUpSpinner();
    setUpGround();

    setUpOnPause();
    setUpOnResume();
    setUpOnFinish();

    setUpButtons();
    setUpLabels();
}
 
Example 28
Project: Planet-Generator   File: GameUI.java   Source Code and License 5 votes vote down vote up
public GameUI(PlanetGeneratorGame game) {
    this.game = game;
    this.scene = game.getScene();
    stage = new Stage();

    initialize();
}
 
Example 29
Project: Catan   File: KnightActionsWindow.java   Source Code and License 5 votes vote down vote up
@Override
protected void setStage(Stage stage) {
    super.setStage(stage);
    // Every time this window is displayed, do these checks...
    Knight knight = knightActor.getKnight();
    promoteButton.setDisabled(knight.is(MIGHTY) || knight.isPromotedThisTurn());
    activateButton.setDisabled(knight.isActive() || knight.isActivatedThisTurn());
    moveButton.setDisabled(!knight.isActive() || knight.isActivatedThisTurn());
}
 
Example 30
Project: Catan   File: SignUpScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    bg = new Texture("BG.png");
    bg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);

    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    if (skin == null)
        createBasicSkin();

    // Create & add the window
    CatanWindow window = new CatanWindow(TITLE, skin);
    stage.addActor(window);

    Label usernameLabel = new Label ("Username:", skin);
    TextField usernameText = new TextField ("", skin);
    Label passwordLabel = new Label ("Password:", skin);
    TextField passwordText = new TextField("", skin);

    /*//Create table
    Table mainTable = new Table();
    //add labels to table
    mainTable.add(usernameLabel);
    mainTable.add(usernameText).width(200);
    mainTable.row();
    mainTable.add(passwordLabel);
    mainTable.add(passwordText).width(200);

    mainTable.setFillParent(true);
    stage.addActor(mainTable);*/
}
 
Example 31
Project: NoRiskNoFun   File: SceneBase.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor taking scene name and color used to clear background.
 * @param sceneName Scene's name.
 * @param clearColor Color used to clear background.
 */
protected SceneBase(String sceneName, Color clearColor) {

    this.sceneName = sceneName;
    this.clearColor = clearColor;
    sceneObjects = new LinkedList<>();
    stage = new Stage();
}
 
Example 32
Project: skycity   File: Chat.java   Source Code and License 5 votes vote down vote up
public Chat(SpriteBatch batch){
    field = new TextField("", Assets.getInstance().getSkin());
    field.setVisible(false);

    table = new Table();
    table.bottom().padLeft(20).padRight(20).padBottom(10).setFillParent(true);
    table.setDebug(false);
    table.add(field).width(Config.SCREEN_WIDTH-40);
    stage = new Stage(new FillViewport(Config.SCREEN_WIDTH,Config.SCREEN_HEIGHT,new OrthographicCamera()),batch);
    stage.addActor(table);
    stage.setKeyboardFocus(field);
}
 
Example 33
Project: SuperUI   File: Handle.java   Source Code and License 5 votes vote down vote up
/**
 * A Handle can overwrite this function if you don't want to use the default
 * variadic parameter parsing.
 * 
 * @param parent
 * @param variadic
 */
public void initialise(Stage parent, Object... variadic) {
	this.parent = parent;

	int length = variadic.length;
	for (int i = 0; i < length; i++) {
		Object o = variadic[i];

		/** Register the class we get */
		register(o.getClass(), o);
	}
}
 
Example 34
Project: conquest   File: Match.java   Source Code and License 5 votes vote down vote up
public Match(Client client, Player player) {
    Match.client = client;
    this.tiles = Match.client.getMap();
    this.player = player;

    cam = new ConquestCamera(this.tiles);
    stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), cam));

    Group tileGroup = new Group();
    Group labelGroup = new Group();
    for (Tile t : this.tiles) {
        t.setTexture();
        tileGroup.addActor(t);
        labelGroup.addActor(t.getLabel());
    }

    Tile random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    while (random.getOwner() != Owner.None) {
        random = this.tiles.get(MathUtils.random(this.tiles.size - 1));
    }
    player.setCapital(random);
    client.send(random);

    cam.position.set(random.getX(Align.center), random.getY(Align.center), 0);

    stage.addActor(tileGroup);
    stage.addActor(labelGroup);
}
 
Example 35
Project: projecttd   File: OptionsScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    VisUI.load();

    CenteredTableBuilder tableBuilder = new CenteredTableBuilder(new Padding(2, 3));

    VisLabel heading = new VisLabel("Options");
    heading.setColor(Color.BLACK);
    tableBuilder.append(heading).row();
    stage.addActor(heading);

    VisLabel temp = new VisLabel("To Be Implemented");
    temp.setColor(Color.BLACK);
    tableBuilder.append(temp).row();
    stage.addActor(temp);

    VisTextButton backButton = new VisTextButton("Back");
    backButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenuScreen());
        }
    });
    tableBuilder.append(backButton).row();
    stage.addActor(backButton);

    Table table = tableBuilder.build();
    table.setFillParent(true);
    stage.addActor(table);
}
 
Example 36
Project: gdx-controllerutils   File: ControllerMenuDialog.java   Source Code and License 5 votes vote down vote up
@Override
protected void setStage(Stage stage) {
    if (stage == null && getStage() != null && getStage() instanceof ControllerMenuStage) {
        for (int i = 0; i < buttonsToAdd.size; i++)
            ((ControllerMenuStage) getStage()).removeFocussableActor(buttonsToAdd.get(i));
    }

    super.setStage(stage);

    if (stage != null && stage instanceof ControllerMenuStage) {
        for (int i = 0; i < buttonsToAdd.size; i++)
            ((ControllerMenuStage) stage).addFocussableActor(buttonsToAdd.get(i));
    }
}
 
Example 37
Project: Tower-Defense-Galaxy   File: TDScreen.java   Source Code and License 5 votes vote down vote up
@Override
public void show () {
    //orthographicCamera = new OrthographicCamera(3840, 2160);
    matrix4 = new Matrix4();
    spriteBatch = new SpriteBatch();
    viewport = new FitViewport(2560, 1440, new OrthographicCamera());
    viewport.apply();
    stage = new Stage(viewport);
    camera = createCamera();
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(stage);
    Gdx.input.setInputProcessor(multiplexer);
    if(TDGalaxy.preferences.isDebug())
        stage.setDebugAll(true);
}
 
Example 38
Project: KyperBox   File: KyperBoxGame.java   Source Code and License 5 votes vote down vote up
@Override
public void create() {
	game_prefs = Gdx.app.getPreferences(prefs_name);

	game_stage = new Stage(view);
	game_states = new ObjectMap<String, GameState>();
	game_stage.setDebugAll(false);

	current_gamestates = new Array<GameState>();
	transition_state = new GameState(null);
	transition_state.setGame(this);

	assets = new AssetManager();
	assets.setLoader(TiledMap.class, new KyperMapLoader(assets.getFileHandleResolver()));
	assets.setLoader(ParticleEffect.class, new ParticleEffectLoader(assets.getFileHandleResolver()));
	assets.setLoader(ShaderProgram.class,
			new ShaderProgramLoader(assets.getFileHandleResolver(), VERTEX_SUFFIX, FRAGMENT_SUFFIX));
	sound = new SoundManager(this);

	packages = new Array<String>();
	packages.add("com.kyperbox.objects");

	global_data = new UserData(GAME_DATA_NAME);
	input = new GameInput();

	Gdx.input.setInputProcessor(game_stage);

	initiate();
}
 
Example 39
Project: summer17-android   File: Hud.java   Source Code and License 5 votes vote down vote up
public Hud(SpriteBatch sb) {
        worldTimer = 300;
        timeCount = 0;
        score = 0;

        viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
        stage = new Stage(viewport, sb);

        Table table = new Table();
        table.top();
        table.setFillParent(true);

//        countDownLabel = new Label(String.format("%03d", worldTimer), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
//        dudeLabel = new Label("DUDE", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

        table.add(dudeLabel).expandX().padTop(10);
        table.add(worldLabel).expandX().padTop(10);
        table.add(timeLabel).expandX().padTop(10);
        table.row();
        table.add(scoreLabel).expandX();
        table.add(levelLabel).expandX();
        table.add(countDownLabel).expandX();

        stage.addActor(table);
    }
 
Example 40
Project: summer17-android   File: EndScreen.java   Source Code and License 5 votes vote down vote up
public EndScreen(NoObjectionGame game) {
    this.game = game;
    bg = new Texture("pixil-layer-Background2.png");
    viewport = new StretchViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, ((NoObjectionGame) game).batch);

}
 
Example 41
Project: summer17-android   File: WinScreen.java   Source Code and License 5 votes vote down vote up
public WinScreen(NoObjectionGame game) {
    this.game = game;
    bg = new Texture("pixil-layer-Background.png");
    viewport = new StretchViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, ((NoObjectionGame) game).batch);

}
 
Example 42
Project: blueirisviewer   File: UI.java   Source Code and License 5 votes vote down vote up
public UI()
{
	uiElements = new ArrayList<UIElement>();

	stage = new Stage(new ScreenViewport());
	skin = new Skin(Gdx.files.internal("data/uiskin.json"));

	root = new WidgetGroup();
	root.setFillParent(true);
	stage.addActor(root);

	new MainOptionsWnd(skin);
}
 
Example 43
Project: summer17-android   File: PlayScreen.java   Source Code and License 5 votes vote down vote up
public PlayScreen(NoObjectionGame game) {
    atlas = new TextureAtlas("dudestuff3.pack");

    this.game = game;
    bg = new Texture("main_background.png");
    gameCam = new OrthographicCamera();
    gamePort = new FitViewport(NoObjectionGame.V_WIDTH / NoObjectionGame.PPM, NoObjectionGame.V_HEIGHT / NoObjectionGame.PPM, gameCam);
    hud = new Hud(game.batch);

    maploader = new TmxMapLoader();
    map = maploader.load("map1.tmx");
    renderer = new OrthoCachedTiledMapRenderer(map, 1 / NoObjectionGame.PPM);
    gameCam.position.set(gamePort.getWorldWidth() / 2, gamePort.getWorldHeight() / 2, 0);

    world = new World(new Vector2(0, -10), true);
    b2dr = new Box2DDebugRenderer();

    new B2WorldCreator(world, map);
    hero = new Hero(world, this);
    controller = new Controller();
    worldContactListener = new WorldContactListener();
    world.setContactListener(worldContactListener);

    //timer
    sb = new SpriteBatch();
    viewport = new FitViewport(NoObjectionGame.V_WIDTH, NoObjectionGame.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);
    table = new Table();
    table.top();
    table.setFillParent(true);
    countDownLabel = new Label(Float.toString(playTime), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    table.add(countDownLabel).expandX();
    stage.addActor(table);


}
 
Example 44
Project: enklave   File: ScreenRaider.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    if(!draw){
        draw = true;
        addBackground();
        addtoStage();
    }
    stage = new Stage(new StretchViewport(Width,Height));
    decalBatch = new DecalBatch(new CameraGroupStrategy(camera));
    stage.addActor(groupStage);
    modelBatch = new ModelBatch();
    Gdx.input.setInputProcessor(stage);
}
 
Example 45
Project: enklave   File: ScreenChoiceFaction.java   Source Code and License 5 votes vote down vote up
@Override
public void show() {
    manager.loadAssetsChoiceFaction();
    manager.getAssetsChoiceFaction().finish();
    make();
    stage = new Stage(new StretchViewport(WIDTH,HEIGHT));
    modelBatch = new ModelBatch();
    stage.addActor(group);
}
 
Example 46
Project: enklave   File: ScreenDescribeEnklave.java   Source Code and License 5 votes vote down vote up
private void addtoStage(Stage st){
    st.addActor(imagebg);
    st.addActor(labelLevel);
    st.addActor(labelName);
    st.addActor(imageleftTop);
    st.addActor(groupDescribeEnklave);
    st.addActor(groupActiveRooms);
    st.addActor(groupActiveExtension);
    st.addActor(groupBuildRoom);
    st.addActor(groupAddExtensions);
}
 
Example 47
Project: retro-reversi   File: DifficultyMenuView.java   Source Code and License 5 votes vote down vote up
public DifficultyMenuView(Reversi game) {
    this.game = game;
    stage = new Stage(game.getViewport(), game.getBatch());

    addTitle();
    addPieceChoice();
    addChoiceButtons();
    addListeners();

    Gdx.input.setInputProcessor(stage);
}
 
Example 48
Project: minihabits   File: AskForProgressView.java   Source Code and License 5 votes vote down vote up
public AskForProgressView(Skin skin, Stage stage, DateAtMidnight date, Collection<MiniHabit> miniHabits) {
	super("Progress feedback", skin);
	this.stage = stage;
	this.date = date;
	this.miniHabits = miniHabits;
	this.miniHabitsByCheckbox = new HashMap<CheckBox, MiniHabit>();

	createUI();
}
 
Example 49
Project: enklave   File: CombatFitght.java   Source Code and License 5 votes vote down vote up
public void AddStage(Stage stage){
//        stage.addActor(groupturret1);
//        stage.addActor(groupturret2);
//        stage.addActor(groupturret3);
        stage.addActor(groupShield);
        stage.addActor(groupButtonAction);
    }
 
Example 50
Project: Polymorph   File: SettingsScreen.java   Source Code and License 5 votes vote down vote up
public SettingsScreen(Polymorph polymorph) {
    AssetManager assetManager = polymorph.getAssetManager();
    TextureAtlas textureAtlas = assetManager.get(Polymorph.MASTER_PATH, TextureAtlas.class);

    this.polymorph = polymorph;

    mainMenuMusic = assetManager.get(Polymorph.MAIN_MENU_MUSIC_PATH, Music.class);
    background = textureAtlas.findRegion("settingsscreen");

    stage = new Stage(new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT));
    stage.clear();
    initButtons(textureAtlas);
    Gdx.input.setInputProcessor(stage);
}
 
Example 51
Project: Polymorph   File: MainMenu.java   Source Code and License 5 votes vote down vote up
private void initStage() {
    stage = new Stage(new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT));
    Gdx.input.setInputProcessor(stage);

    createTitle();
    createButtons();
}
 
Example 52
Project: retro-reversi   File: MultiplayerMenuView.java   Source Code and License 5 votes vote down vote up
public MultiplayerMenuView(Reversi game) {
    this.game = game;
    stage = new Stage(game.getViewport(), game.getBatch());

    addTitle();
    addOptionsButtons();
    addListeners();

    Gdx.input.setInputProcessor(stage);
}
 
Example 53
Project: Particles   File: IntroScreen.java   Source Code and License 5 votes vote down vote up
IntroScreen(final ParticleGame game) {
    particle_game = game;
    stage = new Stage();
    table = new Table();

    table.setFillParent(true);
    table.setDebug(true);
    stage.addActor(table);

    Skin skin = new Skin();
    
    Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.WHITE);
    pixmap.fill();
    
    skin.add("white", new Texture(pixmap));
    skin.add("font", game.getFont());

    TextButton.TextButtonStyle text_button_style = new TextButton.TextButtonStyle();
    final Color button_color = new Color(226 / 255f, 226 / 255f, 226 / 255f, 1f);
    final Color hover_color = new Color(162 / 255f, 162 / 255f, 162 / 255f, 1f);
    text_button_style.up = skin.newDrawable("white", button_color);
    text_button_style.down = skin.newDrawable("white", button_color);
    text_button_style.over = skin.newDrawable("white", hover_color);
    text_button_style.font = skin.getFont("font");
    skin.add("default", text_button_style);

    TextButton play_button = new TextButton("play", skin);
    play_button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            particle_game.setScreen(particle_game.getGameSetupScreen());
        }
    });
    table.add(play_button);
}
 
Example 54
Project: Particles   File: ParticleChoiceScreen.java   Source Code and License 5 votes vote down vote up
private void initStage() {
    stage = new Stage(new ScreenViewport());
    stage.addListener(new InputListener() {
        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            if (keycode == Input.Keys.SPACE) {
                game.setScreen(game_screen);
            }

            return true;
        }
    });
}
 
Example 55
Project: MMORPG_Prototype   File: Assets.java   Source Code and License 5 votes vote down vote up
public static Stage getStage()
{
	for (CustomStage stage : stages)
		if (!stage.isUsed())
		{
			stage.setUsed(true);
			return stage;
		}
	CustomStage newStage = createStage();
	newStage.setUsed(true);
	stages.add(newStage);
	return newStage;
}
 
Example 56
Project: MMORPG_Prototype   File: ShopDialog.java   Source Code and License 5 votes vote down vote up
public ShopDialog(String title, long id, ShopItem[] items,
		Stage stageForPopUpInfos, UserInterface linkedInterface, PacketsSender packetSender)
{
	super(title, linkedInterface.getDialogs(), id);

	ShopPage shopPage = new ShopPage(items, stageForPopUpInfos, linkedInterface, packetSender, id);
	this.getContentTable().add(shopPage);
	this.row();
}
 
Example 57
Project: KyperBox   File: KyperBoxGame.java   Source Code and License 4 votes vote down vote up
public Stage getGameState() {
	return game_stage;
}
 
Example 58
Project: cocos2d-java   File: ModuleGdxUI.java   Source Code and License 4 votes vote down vote up
@Override
	public void onEnter(IScene scene, Object config) {
		CCLog.engine(ModuleId, "onEnter");
		
		GdxUIConfig _config = (GdxUIConfig) config;
		if(_config == null) {
			//默认采用从director获取的设置
			_config = GdxUIConfig.instance();
			_config.uiDefaultWidth = Director.getInstance().getVisibleSize().width;
			_config.uiDefaultHeight = Director.getInstance().getVisibleSize().height;
		}
		
		_stage = new Stage();
//		_stage.s
		
		//default存在就添加
		if(_defaultGroup != null) {
			if(_defaultGroup.getStage() != _stage) {
				_stage.addActor(_defaultGroup);
			}
		}
		
		_manager = new GdxUIManager(this);
		
		//应用配置
		_stage.getCamera().viewportWidth = _config.uiDefaultWidth;
		_stage.getCamera().viewportHeight = _config.uiDefaultHeight;
		_stage.getCamera().position.set(
				_stage.getCamera().viewportWidth/2f, 
				_stage.getCamera().viewportHeight/2f, 0);
		
		_stage.getViewport().setWorldWidth(_config.uiDefaultWidth);
		_stage.getViewport().setWorldHeight(_config.uiDefaultHeight);
		
		BaseInput.instance().addInputProcessor(_stage);
		Scheduler _scheduler = Director.getInstance().getScheduler();
		//visit 渲染完再处理这个
		renderFuncHandler = _scheduler.renderAfterSchedulePerFrame(renderFunc, 0, false);
		
		_stage.setDebugAll(false);
	}
 
Example 59
Project: Cubes   File: Menu.java   Source Code and License 4 votes vote down vote up
public Menu() {
  stage = new Stage(screenViewport, spriteBatch);
}
 
Example 60
Project: LD38-Compo   File: LudumDare38.java   Source Code and License 4 votes vote down vote up
@Override
public void create () {

	loadHighScore();
	stage = new Stage();
	group = new WidgetGroup();
	stage.addActor(group);
	createToolTip();
	createResetButton();
	createUndoButton();
	batch = new SpriteBatch();
	polyBatch = new PolygonSpriteBatch();

	HexagonalGridBuilder<TileData> builder = new HexagonalGridBuilder<TileData>()
			.setGridHeight(GRID_WIDTH)
			.setGridWidth(GRID_HEIGHT)
			.setGridLayout(HexagonalGridLayout.HEXAGONAL)
			.setOrientation(HexagonOrientation.FLAT_TOP)
			.setRadius(Gdx.graphics.getWidth()/16);

	grid = builder.build();
	initHexData();
	initInput();
	shapeRenderer = new ShapeRenderer();
	shapeRenderer.setAutoShapeType(true);

	AssetLoader.load();

	String vertexShader = Gdx.files.internal("defaultvertex.vs").readString();
	String redShader = Gdx.files.internal("redtrans.fs").readString();
	invalidPlacement = new ShaderProgram(vertexShader, redShader);
	if (!invalidPlacement.isCompiled()) throw new GdxRuntimeException("Couldn't compile shader: " + invalidPlacement.getLog());

	String okShader = Gdx.files.internal("slightlytrans.fs").readString();
	okPlacement = new ShaderProgram(vertexShader, okShader);
	if (!okPlacement.isCompiled()) throw new GdxRuntimeException("Couldn't compile shader: " + okPlacement.getLog());

	initGrid();

	menuTextures = new ArrayList<>();
	menuTextures.add(AssetLoader.assetManager.get("farm.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("house.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("mine.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("wind.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("factory.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("market.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("bank.png", Texture.class));
	menuTextures.add(AssetLoader.assetManager.get("rocket.png", Texture.class));

	for(int i = 0; i < START_CLOUDS_COUNT; i++)
	{
		Coord c = new Coord();
		c.x = r.nextInt() % Gdx.graphics.getWidth();
		c.y = r.nextInt() % Gdx.graphics.getHeight();
		clouds.add(c);
	}
}