Search in sources :

Example 1 with TouchArea

use of com.watabou.noosa.TouchArea in project PD-classes by watabou.

the class Button method createChildren.

@Override
protected void createChildren() {
    hotArea = new TouchArea(0, 0, 0, 0) {

        @Override
        protected void onTouchDown(Touch touch) {
            pressed = true;
            pressTime = 0;
            processed = false;
            Button.this.onTouchDown();
        }

        ;

        @Override
        protected void onTouchUp(Touch touch) {
            pressed = false;
            Button.this.onTouchUp();
        }

        ;

        @Override
        protected void onClick(Touch touch) {
            if (!processed) {
                Button.this.onClick();
            }
        }

        ;
    };
    add(hotArea);
}
Also used : TouchArea(com.watabou.noosa.TouchArea) Touch(com.watabou.input.Touchscreen.Touch)

Example 2 with TouchArea

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

the class SurfaceScene method create.

@Override
public void create() {
    super.create();
    Music.INSTANCE.play(Assets.HAPPY, true);
    Music.INSTANCE.volume(1f);
    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) / 2);
    float vy = align((h - SKY_HEIGHT - BUTTON_HEIGHT) / 2);
    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 = !Dungeon.nightMode;
    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);
    a.x = PixelScene.align((SKY_WIDTH - a.width) / 2);
    a.y = SKY_HEIGHT - a.height;
    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;
    window.add(pet);
    window.add(new TouchArea(sky) {

        protected void onClick(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("Game Over") {

        protected void onClick() {
            Game.switchScene(TitleScene.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) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) Point(com.watabou.utils.Point) Archs(com.watabou.pixeldungeon.ui.Archs) TouchArea(com.watabou.noosa.TouchArea) Camera(com.watabou.noosa.Camera) RedButton(com.watabou.pixeldungeon.ui.RedButton) ColorBlock(com.watabou.noosa.ColorBlock)

Example 3 with TouchArea

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

the class AboutScene method create.

@Override
public void create() {
    super.create();
    BitmapTextMultiline text = createMultiline(TXT, 8);
    text.maxWidth = Math.min(Camera.main.width, 120);
    text.measure();
    add(text);
    text.x = align((Camera.main.width - text.width()) / 2);
    text.y = align((Camera.main.height - text.height()) / 2);
    BitmapTextMultiline link = createMultiline(LNK, 8);
    link.maxWidth = Math.min(Camera.main.width, 120);
    link.measure();
    link.hardlight(Window.TITLE_COLOR);
    add(link);
    link.x = text.x;
    link.y = text.y + text.height();
    TouchArea hotArea = new TouchArea(link) {

        @Override
        protected void onClick(Touch touch) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://" + LNK));
            Game.instance.startActivity(intent);
        }
    };
    add(hotArea);
    Image wata = Icons.WATA.get();
    wata.x = align((Camera.main.width - wata.width) / 2);
    wata.y = text.y - wata.height - 8;
    add(wata);
    new Flare(7, 64).color(0x112233, true).show(wata, 0).angularSpeed = +20;
    Archs archs = new Archs();
    archs.setSize(Camera.main.width, Camera.main.height);
    addToBack(archs);
    ExitButton btnExit = new ExitButton();
    btnExit.setPos(Camera.main.width - btnExit.width(), 0);
    add(btnExit);
    fadeIn();
}
Also used : Flare(com.watabou.pixeldungeon.effects.Flare) TouchArea(com.watabou.noosa.TouchArea) Archs(com.watabou.pixeldungeon.ui.Archs) ExitButton(com.watabou.pixeldungeon.ui.ExitButton) Intent(android.content.Intent) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) BitmapTextMultiline(com.watabou.noosa.BitmapTextMultiline)

Example 4 with TouchArea

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

the class SimpleButton method createChildren.

@Override
protected void createChildren() {
    image = new Image();
    add(image);
    add(new TouchArea(image) {

        @Override
        protected void onTouchDown(Touch touch) {
            image.brightness(1.2f);
        }

        ;

        @Override
        protected void onTouchUp(Touch touch) {
            image.brightness(1.0f);
        }

        ;

        @Override
        protected void onClick(Touch touch) {
            SimpleButton.this.onClick();
        }

        ;
    });
}
Also used : TouchArea(com.watabou.noosa.TouchArea) Image(com.watabou.noosa.Image) Touch(com.watabou.input.Touchscreen.Touch)

Example 5 with TouchArea

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

the class StatusPane method createChildren.

@Override
protected void createChildren() {
    shield = new NinePatch(Assets.STATUS, 80, 0, 30 + 18, 0);
    add(shield);
    add(new TouchArea(0, 1, 30, 30) {

        @Override
        protected void onClick(Touch touch) {
            Image sprite = Dungeon.hero.sprite;
            if (!sprite.isVisible()) {
                Camera.main.focusOn(sprite);
            }
            GameScene.show(new WndHero());
        }

        ;
    });
    btnMenu = new MenuButton();
    add(btnMenu);
    avatar = HeroSprite.avatar(Dungeon.hero.heroClass, lastTier);
    add(avatar);
    blood = new BitmaskEmitter(avatar);
    blood.pour(BloodParticle.FACTORY, 0.3f);
    blood.autoKill = false;
    blood.on = false;
    add(blood);
    compass = new Compass(Dungeon.level.exit);
    add(compass);
    hp = new Image(Assets.HP_BAR);
    add(hp);
    exp = new Image(Assets.XP_BAR);
    add(exp);
    level = new BitmapText(PixelScene.font1x);
    level.hardlight(0xFFEBA4);
    add(level);
    depth = new BitmapText(Integer.toString(Dungeon.depth), PixelScene.font1x);
    depth.hardlight(0xCACFC2);
    depth.measure();
    add(depth);
    Dungeon.hero.belongings.countIronKeys();
    keys = new BitmapText(PixelScene.font1x);
    keys.hardlight(0xCACFC2);
    add(keys);
    danger = new DangerIndicator();
    add(danger);
    loot = new LootIndicator();
    add(loot);
    resume = new ResumeButton();
    add(resume);
    buffs = new BuffIndicator(Dungeon.hero);
    add(buffs);
}
Also used : NinePatch(com.watabou.noosa.NinePatch) Touch(com.watabou.input.Touchscreen.Touch) Image(com.watabou.noosa.Image) WndHero(com.watabou.pixeldungeon.windows.WndHero) BitmaskEmitter(com.watabou.noosa.particles.BitmaskEmitter) TouchArea(com.watabou.noosa.TouchArea) BitmapText(com.watabou.noosa.BitmapText)

Aggregations

Touch (com.watabou.input.Touchscreen.Touch)5 TouchArea (com.watabou.noosa.TouchArea)5 Image (com.watabou.noosa.Image)4 Archs (com.watabou.pixeldungeon.ui.Archs)2 Intent (android.content.Intent)1 BitmapText (com.watabou.noosa.BitmapText)1 BitmapTextMultiline (com.watabou.noosa.BitmapTextMultiline)1 Camera (com.watabou.noosa.Camera)1 ColorBlock (com.watabou.noosa.ColorBlock)1 Group (com.watabou.noosa.Group)1 NinePatch (com.watabou.noosa.NinePatch)1 BitmaskEmitter (com.watabou.noosa.particles.BitmaskEmitter)1 Flare (com.watabou.pixeldungeon.effects.Flare)1 ExitButton (com.watabou.pixeldungeon.ui.ExitButton)1 RedButton (com.watabou.pixeldungeon.ui.RedButton)1 WndHero (com.watabou.pixeldungeon.windows.WndHero)1 Point (com.watabou.utils.Point)1