Search in sources :

Example 41 with Image

use of com.watabou.noosa.Image in project pixel-dungeon by watabou.

the class DungeonTilemap method discover.

public void discover(int pos, int oldValue) {
    final Image tile = tile(oldValue);
    tile.point(tileToWorld(pos));
    // For bright mode
    tile.rm = tile.gm = tile.bm = rm;
    tile.ra = tile.ga = tile.ba = ra;
    parent.add(tile);
    parent.add(new AlphaTweener(tile, 0, 0.6f) {

        protected void onComplete() {
            tile.killAndErase();
            killAndErase();
        }
    });
}
Also used : AlphaTweener(com.watabou.noosa.tweeners.AlphaTweener) Image(com.watabou.noosa.Image)

Example 42 with Image

use of com.watabou.noosa.Image in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Fireball method createChildren.

@Override
protected void createChildren() {
    sparks = new Group();
    add(sparks);
    bLight = new Image(Assets.FIREBALL);
    bLight.frame(BLIGHT);
    bLight.origin.set(bLight.width / 2);
    bLight.angularSpeed = -90;
    add(bLight);
    emitter = new Emitter();
    emitter.pour(new Emitter.Factory() {

        @Override
        public void emit(Emitter emitter, int index, float x, float y) {
            Flame p = (Flame) emitter.recycle(Flame.class);
            p.reset();
            p.heightLimit(Fireball.this.y - 30);
            p.x = x - p.width / 2;
            p.y = y - p.height / 2;
        }
    }, 0.1f);
    add(emitter);
    fLight = new Image(Assets.FIREBALL);
    fLight.frame(FLIGHT);
    fLight.origin.set(fLight.width / 2);
    fLight.angularSpeed = 360;
    add(fLight);
    bLight.texture.filter(Texture.LINEAR, Texture.LINEAR);
}
Also used : Group(com.watabou.noosa.Group) Emitter(com.watabou.noosa.particles.Emitter) Image(com.watabou.noosa.Image)

Example 43 with Image

use of com.watabou.noosa.Image in project shattered-pixel-dungeon-gdx by 00-Evan.

the class AmuletScene method create.

@Override
public void create() {
    super.create();
    RenderedTextMultiline text = null;
    if (!noText) {
        text = renderMultiline(Messages.get(this, "text"), 8);
        text.maxWidth(WIDTH);
        add(text);
    }
    amulet = new Image(Assets.AMULET);
    add(amulet);
    RedButton btnExit = new RedButton(Messages.get(this, "exit")) {

        @Override
        protected void onClick() {
            Dungeon.win(Amulet.class);
            Dungeon.deleteGame(GamesInProgress.curSlot, true);
            Game.switchScene(RankingsScene.class);
        }
    };
    btnExit.setSize(WIDTH, BTN_HEIGHT);
    add(btnExit);
    RedButton btnStay = new RedButton(Messages.get(this, "stay")) {

        @Override
        protected void onClick() {
            onBackPressed();
        }
    };
    btnStay.setSize(WIDTH, BTN_HEIGHT);
    add(btnStay);
    float height;
    if (noText) {
        height = amulet.height + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height();
        amulet.x = (Camera.main.width - amulet.width) / 2;
        amulet.y = (Camera.main.height - height) / 2;
        align(amulet);
        btnExit.setPos((Camera.main.width - btnExit.width()) / 2, amulet.y + amulet.height + LARGE_GAP);
        btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP);
    } else {
        height = amulet.height + LARGE_GAP + text.height() + LARGE_GAP + btnExit.height() + SMALL_GAP + btnStay.height();
        amulet.x = (Camera.main.width - amulet.width) / 2;
        amulet.y = (Camera.main.height - height) / 2;
        align(amulet);
        text.setPos((Camera.main.width - text.width()) / 2, amulet.y + amulet.height + LARGE_GAP);
        align(text);
        btnExit.setPos((Camera.main.width - btnExit.width()) / 2, text.top() + text.height() + LARGE_GAP);
        btnStay.setPos(btnExit.left(), btnExit.bottom() + SMALL_GAP);
    }
    new Flare(8, 48).color(0xFFDDBB, true).show(amulet, 0).angularSpeed = +30;
    fadeIn();
}
Also used : Flare(com.shatteredpixel.shatteredpixeldungeon.effects.Flare) RenderedTextMultiline(com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline) RedButton(com.shatteredpixel.shatteredpixeldungeon.ui.RedButton) Image(com.watabou.noosa.Image)

Example 44 with Image

use of com.watabou.noosa.Image in project shattered-pixel-dungeon-gdx by 00-Evan.

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    uiCamera.visible = false;
    int w = Camera.main.width;
    int h = Camera.main.height;
    Archs archs = new Archs();
    archs.reversed = true;
    archs.setSize(w, h);
    add(archs);
    float vx = align((w - SKY_WIDTH) / 2f);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2f);
    Point s = Camera.main.cameraToScreen(vx, vy);
    viewport = new Camera(s.x, s.y, SKY_WIDTH, SKY_HEIGHT, defaultZoom);
    Camera.add(viewport);
    Group window = new Group();
    window.camera = viewport;
    add(window);
    boolean dayTime = Calendar.getInstance().get(Calendar.HOUR_OF_DAY) >= 7;
    Sky sky = new Sky(dayTime);
    sky.scale.set(SKY_WIDTH, SKY_HEIGHT);
    window.add(sky);
    if (!dayTime) {
        for (int i = 0; i < NSTARS; i++) {
            float size = Random.Float();
            ColorBlock star = new ColorBlock(size, size, 0xFFFFFFFF);
            star.x = Random.Float(SKY_WIDTH) - size / 2;
            star.y = Random.Float(SKY_HEIGHT) - size / 2;
            star.am = size * (1 - star.y / SKY_HEIGHT);
            window.add(star);
        }
    }
    float range = SKY_HEIGHT * 2 / 3;
    for (int i = 0; i < NCLOUDS; i++) {
        Cloud cloud = new Cloud((NCLOUDS - 1 - i) * (range / NCLOUDS) + Random.Float(range / NCLOUDS), dayTime);
        window.add(cloud);
    }
    int nPatches = (int) (sky.width() / GrassPatch.WIDTH + 1);
    for (int i = 0; i < nPatches * 4; i++) {
        GrassPatch patch = new GrassPatch((i - 0.75f) * GrassPatch.WIDTH / 4, SKY_HEIGHT + 1, dayTime);
        patch.brightness(dayTime ? 0.7f : 0.4f);
        window.add(patch);
    }
    Avatar a = new Avatar(Dungeon.hero.heroClass);
    // Removing semitransparent contour
    a.am = 2;
    a.aa = -1;
    a.x = (SKY_WIDTH - a.width) / 2;
    a.y = SKY_HEIGHT - a.height;
    align(a);
    window.add(a);
    final Pet pet = new Pet();
    pet.rm = pet.gm = pet.bm = 1.2f;
    pet.x = SKY_WIDTH / 2 + 2;
    pet.y = SKY_HEIGHT - pet.height;
    align(pet);
    window.add(pet);
    window.add(new TouchArea(sky) {

        protected void onClick(NoosaInputProcessor.Touch touch) {
            pet.jump();
        }
    });
    for (int i = 0; i < nPatches; i++) {
        GrassPatch patch = new GrassPatch((i - 0.5f) * GrassPatch.WIDTH, SKY_HEIGHT, dayTime);
        patch.brightness(dayTime ? 1.0f : 0.8f);
        window.add(patch);
    }
    Image frame = new Image(Assets.SURFACE);
    frame.frame(0, 0, FRAME_WIDTH, FRAME_HEIGHT);
    frame.x = vx - FRAME_MARGIN_X;
    frame.y = vy - FRAME_MARGIN_TOP;
    add(frame);
    if (dayTime) {
        a.brightness(1.2f);
        pet.brightness(1.2f);
    } else {
        frame.hardlight(0xDDEEFF);
    }
    RedButton gameOver = new RedButton(Messages.get(this, "exit")) {

        protected void onClick() {
            Game.switchScene(RankingsScene.class);
        }
    };
    gameOver.setSize(SKY_WIDTH - FRAME_MARGIN_X * 2, BUTTON_HEIGHT);
    gameOver.setPos(frame.x + FRAME_MARGIN_X * 2, frame.y + frame.height + 4);
    add(gameOver);
    Badges.validateHappyEnd();
    fadeIn();
}
Also used : Group(com.watabou.noosa.Group) Point(com.watabou.utils.Point) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) NoosaInputProcessor(com.watabou.input.NoosaInputProcessor) Camera(com.watabou.noosa.Camera) RedButton(com.shatteredpixel.shatteredpixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 45 with Image

use of com.watabou.noosa.Image in project shattered-pixel-dungeon-gdx by 00-Evan.

the class TitleScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.THEME, true);
    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 topRegion = Math.max(95f, h * 0.45f);
    title.x = (w - title.width()) / 2f;
    if (SPDSettings.landscape())
        title.y = (topRegion - title.height()) / 2f;
    else
        title.y = 16 + (topRegion - title.height() - 16) / 2f;
    align(title);
    placeTorch(title.x + 22, title.y + 46);
    placeTorch(title.x + title.width - 22, title.y + 46);
    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {

        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = Math.max(0f, (float) Math.sin(time += Game.elapsed));
            if (time >= 1.5f * Math.PI)
                time = 0;
        }

        @Override
        public void draw() {
            Blending.setLightMode();
            super.draw();
            Blending.setNormalMode();
        }
    };
    signs.x = title.x + (title.width() - signs.width()) / 2f;
    signs.y = title.y;
    add(signs);
    DashboardItem btnBadges = new DashboardItem(Messages.get(this, "badges"), 3) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(BadgesScene.class);
        }
    };
    add(btnBadges);
    DashboardItem btnAbout = new DashboardItem(Messages.get(this, "about"), 1) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(AboutScene.class);
        }
    };
    add(btnAbout);
    DashboardItem btnPlay = new DashboardItem(Messages.get(this, "play"), 0) {

        @Override
        protected void onClick() {
            if (GamesInProgress.checkAll().size() == 0) {
                TitleScene.this.add(new WndStartGame(1));
            } else {
                ShatteredPixelDungeon.switchNoFade(StartScene.class);
            }
        }
    };
    add(btnPlay);
    DashboardItem btnRankings = new DashboardItem(Messages.get(this, "rankings"), 2) {

        @Override
        protected void onClick() {
            ShatteredPixelDungeon.switchNoFade(RankingsScene.class);
        }
    };
    add(btnRankings);
    if (SPDSettings.landscape()) {
        btnRankings.setPos(w / 2 - btnRankings.width(), topRegion);
        btnBadges.setPos(w / 2, topRegion);
        btnPlay.setPos(btnRankings.left() - btnPlay.width(), topRegion);
        btnAbout.setPos(btnBadges.right(), topRegion);
    } else {
        btnPlay.setPos(w / 2 - btnPlay.width(), topRegion);
        btnRankings.setPos(w / 2, btnPlay.top());
        btnBadges.setPos(w / 2 - btnBadges.width(), btnPlay.top() + DashboardItem.SIZE);
        btnAbout.setPos(w / 2, btnBadges.top());
    }
    BitmapText version = new BitmapText("v " + Game.version + "", pixelFont);
    version.measure();
    version.hardlight(0xCCCCCC);
    version.x = w - version.width();
    version.y = h - version.height();
    add(version);
    Button changes = new ChangesButton();
    changes.setPos(w - changes.width(), h - version.height() - changes.height());
    add(changes);
    int pos = 0;
    PrefsButton btnPrefs = new PrefsButton();
    btnPrefs.setRect(pos, 0, 16, 16);
    add(btnPrefs);
    pos += btnPrefs.width();
    LanguageButton btnLang = new LanguageButton();
    btnLang.setRect(pos, 0, 14, 16);
    add(btnLang);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(w - btnExit.width(), 0);
    add(btnExit);
    UpdateNotification updInfo = new UpdateNotification();
    updInfo.setPos(0, h - updInfo.height());
    add(updInfo);
    fadeIn();
}
Also used : LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) UpdateNotification(com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) Image(com.watabou.noosa.Image) WndStartGame(com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame) Archs(com.shatteredpixel.shatteredpixeldungeon.ui.Archs) BitmapText(com.watabou.noosa.BitmapText) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton) ExitButton(com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton) ChangesButton(com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton) LanguageButton(com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton) Button(com.watabou.noosa.ui.Button) PrefsButton(com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton)

Aggregations

Image (com.watabou.noosa.Image)63 TouchArea (com.watabou.noosa.TouchArea)10 Group (com.watabou.noosa.Group)8 Archs (com.watabou.pixeldungeon.ui.Archs)8 Touch (com.watabou.input.Touchscreen.Touch)7 BitmapText (com.watabou.noosa.BitmapText)6 Emitter (com.watabou.noosa.particles.Emitter)6 AlphaTweener (com.watabou.noosa.tweeners.AlphaTweener)6 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)6 Archs (com.shatteredpixel.shatteredpixeldungeon.ui.Archs)4 NinePatch (com.watabou.noosa.NinePatch)4 Text (com.watabou.noosa.Text)4 Flare (com.watabou.pixeldungeon.effects.Flare)4 Point (com.watabou.utils.Point)4 ExitButton (com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton)3 NoosaInputProcessor (com.watabou.input.NoosaInputProcessor)3 TextureFilm (com.watabou.noosa.TextureFilm)3 RedButton (com.watabou.pixeldungeon.ui.RedButton)3 RectF (android.graphics.RectF)2 Flare (com.shatteredpixel.shatteredpixeldungeon.effects.Flare)2