Search in sources :

Example 1 with PrefsButton

use of com.watabou.pixeldungeon.ui.PrefsButton in project pixel-dungeon by watabou.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    Music.INSTANCE.volume(1f);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.setSize(w, h);
    add(archs);
    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    add(title);
    float height = title.height + (PixelDungeon.landscape() ? DashboardItem.SIZE : DashboardItem.SIZE * 2);
    title.x = (w - title.width()) / 2;
    title.y = (h - height) / 2;
    placeTorch(title.x + 18, title.y + 20);
    placeTorch(title.x + title.width - 18, title.y + 20);
    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {

        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = (float) Math.sin(-(time += Game.elapsed));
        }

        @Override
        public void draw() {
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE);
            super.draw();
            GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
        }
    };
    signs.x = title.x;
    signs.y = title.y;
    add(signs);
    DashboardItem btnBadges = new DashboardItem(TXT_BADGES, 3) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(TXT_ABOUT, 1) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(TXT_PLAY, 0) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(StartScene.class);
        }
    };
    add(btnPlay);
    DashboardItem btnHighscores = new DashboardItem(TXT_HIGHSCORES, 2) {

        @Override
        protected void onClick() {
            PixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnHighscores);
    if (PixelDungeon.landscape()) {
        float y = (h + height) / 2 - DashboardItem.SIZE;
        btnHighscores.setPos(w / 2 - btnHighscores.width(), y);
        btnBadges.setPos(w / 2, y);
        btnPlay.setPos(btnHighscores.left() - btnPlay.width(), y);
        btnAbout.setPos(btnBadges.right(), y);
    } else {
        btnBadges.setPos(w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE);
        btnAbout.setPos(w / 2, (h + height) / 2 - DashboardItem.SIZE);
        btnPlay.setPos(w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE);
        btnHighscores.setPos(w / 2, btnPlay.top());
    }
    BitmapText version = new BitmapText("v " + Game.version, font1x);
    version.measure();
    version.hardlight(0x888888);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setPos(0, 0);
    add(btnPrefs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Archs(com.watabou.pixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) PrefsButton(com.watabou.pixeldungeon.ui.PrefsButton) Image(com.watabou.noosa.Image)

Aggregations

BitmapText (com.watabou.noosa.BitmapText)1 Image (com.watabou.noosa.Image)1 Archs (com.watabou.pixeldungeon.ui.Archs)1 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)1 PrefsButton (com.watabou.pixeldungeon.ui.PrefsButton)1