@Override
  public void create() {

    GeneralStorage.load();
    MenuStorage.load();
    SplashStorage.load();
    MenuStorage.load();
    PauseStorage.load();
    RunningStorage.load();
    GameOverStorage.load();

    GeneralStorage.estado = GeneralStorage.state.splash;
    MenuStorage.HelpTouched = false;
    // Init the particle effect
    particle1 = new ParticleEffect();
    particleLeft = new ParticleEffect();
    particleRight = new ParticleEffect();
    // load the particle, first parameter is path and name file when is the particle,
    // second one the fold when is the particle image.
    particle1.load(Gdx.files.internal("efectos/vuelo2"), Gdx.files.internal("efectos"));
    particleLeft.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos"));
    particleRight.load(Gdx.files.internal("efectos/efLateral3"), Gdx.files.internal("efectos"));
    // Sprites of button of the menu screen to music, sound and button help

    spHelp = new Sprite(GeneralStorage.imgBTHelp);
    spHelp.setSize(GeneralStorage.w / 10, GeneralStorage.w / 10);
    spHelp.setPosition(
        GeneralStorage.w - GeneralStorage.w / 4 - spHelp.getWidth() / 2, GeneralStorage.h / 4);

    // storage the background color
    colorFondo = MenuStorage.spBackGroundGame.getColor();
    // Time to splash screen.
    timer = 100;
  }
 @Override
 public void act(float delta) {
   effect.setPosition(this.getX(), this.getY()); // set to whatever x/y you
   // prefer
   effect.update(delta); // update it
   super.act(delta);
 }
Example #3
0
  @Override
  public void updateSizes() {
    waitingToUpdateSize = true;

    size = 2 * radius;
    lightSize = 10 * radius;

    // increase the distance of the lights based on entity's size
    for (Light aLight : lights) {
      aLight.setDistance(lightSize);
    }

    if (dying) {
      if (originalRadius / 4 > radius) {
        for (Light aLight : lights) aLight.setDistance(lightSize * 0.8f);
      } else {
        for (Light aLight : lights) aLight.setDistance(lightSize * 3f);
      }
    }

    // Increase texture size
    sprite.setSize(size, size);

    // Increase particle size
    // Fireball
    giantEffect.getEmitters().get(0).getScale().setLow(3 * radius);
    giantEffect.getEmitters().get(0).getScale().setHigh(3 * radius);

    // Core
    giantEffect.getEmitters().get(1).getScale().setLow(radius);
    giantEffect.getEmitters().get(1).getScale().setHigh(radius);
  }
Example #4
0
 void openEffect() {
   FileDialog dialog = new FileDialog(editor, "Open Effect", FileDialog.LOAD);
   if (lastDir != null) dialog.setDirectory(lastDir);
   dialog.setVisible(true);
   final String file = dialog.getFile();
   final String dir = dialog.getDirectory();
   if (dir == null || file == null || file.trim().length() == 0) return;
   lastDir = dir;
   ParticleEffect effect = new ParticleEffect();
   try {
     effect.loadEmitters(Gdx.files.absolute(new File(dir, file).getAbsolutePath()));
     editor.effect = effect;
     emitterTableModel.getDataVector().removeAllElements();
     editor.particleData.clear();
   } catch (Exception ex) {
     System.out.println("Error loading effect: " + new File(dir, file).getAbsolutePath());
     ex.printStackTrace();
     JOptionPane.showMessageDialog(editor, "Error opening effect.");
     return;
   }
   for (ParticleEmitter emitter : effect.getEmitters()) {
     emitter.setPosition(
         editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
     emitterTableModel.addRow(new Object[] {emitter.getName(), true});
   }
   editIndex = 0;
   emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
   editor.reloadRows();
 }
Example #5
0
 @Override
 public void update(float delta) {
   if (!active) return;
   timer += delta;
   float a = timer / duration;
   if (a <= 1) {
     position.x = Interpolation.linear.apply(start.x, target.x, a);
     position.y =
         Interpolation.linear.apply(start.y, target.y, a) + ((1 + MathUtils.sinDeg(a * 180)) * 2);
     light.setDistance(1.5f + MathUtils.random(-.25f, .25f));
   } else {
     effect.allowCompletion();
     for (ParticleEmitter emitter : effect.getEmitters()) {
       emitter.setContinuous(false);
     }
     light.setDistance(light.getDistance() * 0.95f);
   }
   light.setPosition(position);
   effect.setPosition(position.x, position.y);
   effect.update(delta);
   if (effect.isComplete()) {
     Gdx.app.log("", "reset");
     FlamingRock.pool.free(this);
   }
 }
Example #6
0
  public static void dispose() {
    texture.dispose();
    bgTexture.dispose();
    bgBackTexture.dispose();

    robotoLt.dispose();
    robotoBlk.dispose();
    panel.dispose();
    fontFilter.dispose();
    fontFilter2.dispose();
    menuBack.dispose();
    smoke.dispose();
    fbShare.dispose();

    collision.dispose();
    jump.dispose();
    jumpSound.dispose();
    dblJump.dispose();
    milestone50.dispose();
    run.dispose();
    hit.dispose();
    milestone.dispose();
    milestone50.dispose();
    select.dispose();
    highScore.dispose();

    smokeParticle.dispose();
    starParticle.dispose();
    platform.dispose();
    nanoRun.dispose();
    //		gpgsAtlas.dispose();

  }
Example #7
0
  public void update() {
    super.update();

    if (dying) {
      addToRadius(-3);

      if (radius - 3 <= 2) doExplosion();
    }

    if (!alreadyMoving) {
      if (angularVelocity == -1)
        entityBody.setAngularVelocity(new Random().nextFloat() * 3.0f + 0.35f);
      else entityBody.setAngularVelocity(angularVelocity);

      entityBody.setLinearVelocity(
          new Vector2(
              (float) (Math.cos(originalDirection) * originalVelocity),
              (float) (Math.sin(originalDirection) * originalVelocity)));
      alreadyMoving = true;
    }

    // update particle emitter's position
    giantEffect.setPosition(entityBody.getPosition().x, entityBody.getPosition().y);
    giantEffect.update(Gdx.graphics.getDeltaTime());
  }
Example #8
0
  public void collect() {
    enterSound.stop();
    getSound.play(ESPGame.game.getSoundVolume() * 3.4f);

    getEffect.reset();
    getEffect.setPosition(position.x, position.y);
    ESPGame.getLevel().addParticleSystem(getEffect);

    remove();

    int r = 1, g = 1, b = 1;
    for (int i = 0; i < ADDITIONALREWARDEDDYS; i++) {
      switch (new Random().nextInt(3)) {
        case 0:
          r++;
          break;
        case 1:
          g++;
          break;
        case 2:
          b++;
          break;
        default:
          i--;
      }
    }
    ESPGame.getLevel().modReserve(0, r);
    ESPGame.getLevel().modReserve(1, g);
    ESPGame.getLevel().modReserve(2, b);

    TextDisplayer d =
        ESPGame.getLevel()
            .createTextDisplayer(
                getPosition(),
                VectorUtils.randomNormalized().scl(.5f),
                TEXTDURATION,
                "+" + r,
                Fontsize.Gross);
    d.setColor(Color.RED);
    d =
        ESPGame.getLevel()
            .createTextDisplayer(
                getPosition(),
                VectorUtils.randomNormalized().scl(.5f),
                TEXTDURATION,
                "+" + g,
                Fontsize.Gross);
    d.setColor(Color.GREEN);
    d =
        ESPGame.getLevel()
            .createTextDisplayer(
                getPosition(),
                VectorUtils.randomNormalized().scl(.5f),
                TEXTDURATION,
                "+" + b,
                Fontsize.Gross);
    d.setColor(Color.BLUE);
  }
 @Override
 public ParticleEffect load(
     AssetManager am, String fileName, FileHandle file, ParticleEffectParameter param) {
   ParticleEffect effect = new ParticleEffect();
   if (param != null && param.atlasFile != null)
     effect.load(file, am.get(param.atlasFile, TextureAtlas.class));
   else if (param != null && param.imagesDir != null) effect.load(file, param.imagesDir);
   else effect.load(file, file.parent());
   return effect;
 }
Example #10
0
  private void loadCurrentProjectParticles(String path) {
    particleEffects.clear();
    FileHandle sourceDir = new FileHandle(path);
    for (FileHandle entry : sourceDir.list()) {
      File file = entry.file();
      String filename = file.getName();
      if (file.isDirectory() || filename.endsWith(".DS_Store")) continue;

      ParticleEffect particleEffect = new ParticleEffect();
      particleEffect.load(Gdx.files.internal(file.getAbsolutePath()), currentProjectAtlas, "");
      particleEffects.put(filename, particleEffect);
    }
  }
Example #11
0
  public void init(float x, float y, float tx, float ty) {
    position.set(x, y);
    start.set(position);
    target.set(tx, ty);
    effect.reset();
    duration = target.dst(position) / 6;
    active = true;
    light.setActive(true);
    light.setPosition(x, y);

    for (ParticleEmitter emitter : effect.getEmitters()) {
      emitter.setContinuous(true);
    }
  }
Example #12
0
  public Ship(
      String appearanceLocation,
      float collisionScale,
      World world,
      float startX,
      float startY,
      float maxV,
      ArrayList<ViewedCollidable> aliveThings,
      int factionCode) {
    super(appearanceLocation, collisionScale, world, startX, startY, aliveThings, factionCode);
    // TODO Auto-generated constructor stub
    m_maxVelocity = maxV;
    me = new InertialManeuverEngine(this, maxV);
    ce = new ConventionalCruiseEngine(this, maxV);
    m_aliveThings = aliveThings;

    m_shieldEffect.load(
        Gdx.files.internal("data/shield.p"),
        Gdx.files.internal("data/" + appearanceLocation + "/"));
    m_shieldEffectPool = new ParticleEffectPool(m_shieldEffect, 1, 2);
    m_pooledShieldEffect = m_shieldEffectPool.obtain();

    m_starSlingEnterEffect.load(
        Gdx.files.internal("data/starsling.p"), Gdx.files.internal("data/"));
    m_starSlingEnterEffectPool = new ParticleEffectPool(m_starSlingEnterEffect, 1, 2);
    m_pooledStarSlingEnterEffect = m_starSlingEnterEffectPool.obtain();

    m_starSlingExitEffect.load(
        Gdx.files.internal("data/starslingexit.p"), Gdx.files.internal("data/"));
    m_starSlingExitEffectPool = new ParticleEffectPool(m_starSlingExitEffect, 1, 2);
    m_pooledStarSlingExitEffect = m_starSlingExitEffectPool.obtain();

    float radius = Math.max(m_objectAppearance.getWidth(), m_objectAppearance.getHeight());
    m_pooledStarSlingEnterEffect.getEmitters().get(0).getSpawnHeight().setHigh(radius);
    m_pooledStarSlingEnterEffect.getEmitters().get(0).getSpawnWidth().setHigh(radius);
    m_pooledStarSlingEnterEffect.getEmitters().get(1).getScale().setHigh(radius * 2);
    m_pooledStarSlingEnterEffect.getEmitters().get(1).getScale().setLow(radius);
    m_pooledStarSlingEnterEffect.reset();

    m_pooledStarSlingExitEffect.getEmitters().get(0).getSpawnHeight().setHigh(radius);
    m_pooledStarSlingExitEffect.getEmitters().get(0).getSpawnWidth().setHigh(radius);
    m_pooledStarSlingExitEffect.getEmitters().get(1).getScale().setHigh(radius * 2);
    m_pooledStarSlingExitEffect.getEmitters().get(1).getScale().setLow(radius);
    m_pooledStarSlingExitEffect.reset();

    m_detectionRange = 50f;
    m_font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), false);
    m_shieldDamageReductions[DamageType.Energy.value] = 1f;
  }
Example #13
0
  public void draw(SpriteBatch batch) {
    batch.end();

    stage.getBatch().setProjectionMatrix(stage.getCamera().combined);
    if (eff != null) {
      if (lastHeroPositionX == 0) lastHeroPositionX = (int) RPG.ctrl.hero.getHeadHero().position.x;
      else {
        if (lastHeroPositionX != RPG.ctrl.hero.getHeadHero().position.x) {
          if (lastHeroPositionX > RPG.ctrl.hero.getHeadHero().position.x) { // LEFT
            eff.getEmitters().get(0).getVelocity().setHigh(500, 500);
          } else {
            eff.getEmitters().get(0).getVelocity().setHigh(-500, -500);
          }
        } else {
          eff.getEmitters().get(0).getVelocity().setHigh(0, 0);
        }
        lastHeroPositionX = (int) RPG.ctrl.hero.getHeadHero().position.x;
      }
      eff.setPosition(0, GameUtil.getScreenHeight());

      stage.getBatch().begin();
      eff.draw(stage.getBatch(), Gdx.graphics.getDeltaTime());
      stage.getBatch().end();

      if (eff.isComplete()) eff.reset();
    }

    batch.begin();
  }
Example #14
0
  public void dispose() {
    for (Cell cell : topbar.getCells()) {
      ((TopBar) cell.getActor()).dispose();
    }

    stage.dispose();
    render.dispose();
    add.dispose();
  }
Example #15
0
 public void init(Weather type) {
   this.type = type;
   RPG.global.weather = type;
   if (eff != null) eff.dispose();
   if (stage == null)
     stage =
         new Stage(
             new ScalingViewport(Scaling.stretch, 1024, 576, new OrthographicCamera()),
             GameViews.batch);
   if (type == Weather.rain) {
     eff = new ParticleEffect();
     eff.load(
         Gdx.files.internal(Setting.PARTICLE + "rainp.p"), Gdx.files.internal(Setting.PARTICLE));
     eff.start();
   } else {
     eff = null;
   }
   logic();
 }
Example #16
0
  private void init() {
    r = new Random();
    showedUp = false;
    start = new Vector2();
    target = new Vector2();
    setOrbitable(false);
    double x = calculatePosition();
    double alpha = r.nextDouble() * Math.PI * 2;
    target.set((float) (Math.cos(alpha) * x), (float) (Math.sin(alpha) * x));
    radius = RADIUS;
    setlifespan(BACKUPLIFESPAWN);

    AssetLoader loader = AssetLoader.get();
    enterSound = loader.getSound(AssetContainer.SOUND_HEMAN_ENTER);
    getSound = loader.getSound(AssetContainer.SOUND_HEMAN_GET);
    twinkle = loader.getSound(AssetContainer.SOUND_TWINKLE);
    sprite = new Sprite(loader.getTexture(AssetContainer.HEMAN));

    velocity = new Vector2(target);
    if (r.nextBoolean()) velocity.rotate90(1);
    else velocity.rotate90(-1);
    // TODO does this work? do it better with 'nextFloat' ?

    start = new Vector2(velocity);
    start.scl(10);
    start = start.add(target);
    velocity.scl(-1 * VELOCITIYMULTYPLY);

    ParticleEffect effect = new ParticleEffect(ESPGame.getLevel().particleContainer.heman);
    ESPGame.getLevel().addParticleSystem(effect);
    effect.setPosition(this.position.x, this.position.y);
    effect.start();
    particleEffect = effect;

    getEffect = new ParticleEffect(ESPGame.getLevel().particleContainer.hemanGet);

    setPosition(start);
    sprite.setSize(radius * 2, radius * 2);
    sprite.setOriginCenter();
    sprite.setCenter(position.x, position.y);
  }
    @Override
    public void onLoadedResourcesCompleted() {
      final ParticleEffect particleEffect = new ParticleEffect();
      particleEffect.load(
          Gdx.files.internal("data/particles/D.pp"), Gdx.files.internal("data/particles/"));

      SceneStage stage = new SceneStage();
      {
        final ParticleEffectActor actor = new ParticleEffectActor(particleEffect, "balloon");
        actor.setColor(WebColors.GREEN_YELLOW.get());
        actor.setPosition(100, -100);
        stage.addActor(actor);
      }
      {
        final ParticleEffectActor actor = new ParticleEffectActor(particleEffect, "balloon");
        actor.setColor(WebColors.RED.get());
        actor.setPosition(100, -100);
        stage.addActor(actor);
      }
      Engine.setMainScene(stage);
    }
 public void render() {
   spriteBatch
       .getProjectionMatrix()
       .setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
   float delta = Gdx.graphics.getDeltaTime();
   GL10 gl = Gdx.graphics.getGL10();
   gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
   spriteBatch.begin();
   effect.draw(spriteBatch, delta);
   spriteBatch.end();
   fpsCounter += delta;
   if (fpsCounter > 3) {
     fpsCounter = 0;
     int activeCount = emitters.get(emitterIndex).getActiveCount();
     System.out.println(
         activeCount
             + "/"
             + particleCount
             + " particles, FPS: "
             + Gdx.graphics.getFramesPerSecond());
   }
 }
Example #19
0
  @Override
  public void update() {
    if (paused) {
      pauseTimer--;
      if (pauseTimer == 0) paused = false;
    } else {
      position = position.add(velocity);
    }
    sprite.setCenter(position.x, position.y);
    sprite.rotate(ROTATION_INSTANCE + new Random().nextInt(3));
    particleEffect.setPosition(position.x, position.y);

    if (!showedUp && isInScreen()) {
      onEnter();
      showedUp = true;
    }
    if (showedUp && !isInScreen()) {
      ticklifespan();
    }

    // TODO is this distance ok? Magic number?
    if (getPosition().dst2(ESPGame.getLevel().getPlanet().getPosition()) > 5000 * 5000) {
      // System.out.println("HeMan deleted becaouse distance! Last seen
      // at: " + position);
      remove();
    }

    // Summon intro
    float f = position.dst(ESPGame.getLevel().getPlanet().getPosition());
    if (f < INTRODISTANZ && !introplayed) {
      // System.out.println("He-Man befindet sich in der Nähe zum
      // Planeten. Intro!");
      initIntro();
    }

    // System.out.println("HeMan update. Pos: " + position.x + ", " +
    // position.y);
  }
  // this method put all counters at 0.
  public static void setGame() {
    for (int i = 0; i < 18; i++) {
      RunningStorage.side_left[i].setState(0);
      RunningStorage.side_right[i].setState(1);
      RunningStorage.side_left[i].setPosition(
          -RunningStorage.side_left[i].spSpike.getWidth(),
          (float) (GeneralStorage.h - GeneralStorage.h * 0.1 - GeneralStorage.h * 0.05 * i));
      RunningStorage.side_right[i].setPosition(
          GeneralStorage.w,
          GeneralStorage.h - GeneralStorage.h * 0.1f - GeneralStorage.h * 0.05f * i); //
    }
    counter = 0;
    RunningStorage.changeState = false;
    MenuStorage.spBackGroundGame.setTexture(GeneralStorage.imgBackGround);
    MenuStorage.spBackGroundGame.setColor(colorFondo);
    RunningStorage.pointer = 0;
    RunningStorage.last_touched = 0;
    RunningStorage.array_aleatorios.clear();
    GeneralStorage.bird.spBird.setRotation(RunningStorage.posicion);
    GeneralStorage.bird.setVelocityY((float) (GeneralStorage.h * 0.10));
    GeneralStorage.bird.setDirection_x(1);
    GeneralStorage.bird.spBird.setTexture(GeneralStorage.bird.imgBirdDC);
    GeneralStorage.bird.setPosition(
        GeneralStorage.w / 2 - GeneralStorage.bird.getWidth() / 2,
        GeneralStorage.h / 2
            - GeneralStorage.bird.getHeight() / 2); // position on the middle screen
    GeneralStorage.bird.spBird.setColor(GeneralStorage.color);
    MenuStorage.HelpTouched = false;
    // here reset the particles to restart the game.
    particle1.reset();
    RunningUpDate.touchLeft = false;
    RunningUpDate.touchRight = false;

    if (GameOverUpDate.isReview) GeneralStorage.estado = GeneralStorage.state.menu;
    else GeneralStorage.estado = GeneralStorage.state.running;
    GameOverUpDate.isReview = false;
  }
Example #21
0
 public void draw(SpriteBatch batch) {
   stage.draw();
   SpriteBatch sb = (SpriteBatch) stage.getBatch();
   sb.begin();
   FontUtil.draw(sb, item.name, 22, Color.WHITE, 455, 134, 1000);
   FontUtil.draw(sb, item.illustration, 18, Color.DARK_GRAY, 459, 100, 490);
   scuse.draw(sb);
   if (sellist.isVisible()) sellist.draw(sb, 1);
   scfor.draw(sb);
   if (herolist.isVisible()) {
     herolist.draw(sb, 1);
     sb.flush();
     if (herolist.getSelectedIndex() != -1
         && herolist.getSelected().userObject != null
         && !(herolist.getSelected().userObject instanceof Image)) {
       Hero h = ((Hero) herolist.getSelected().userObject);
       render.begin(ShapeType.Filled);
       render.setColor(green);
       render.rect(
           575, 142, (float) ((float) h.prop.get("hp") / (float) h.prop.get("maxhp")) * 176, 20);
       render.setColor(cblue);
       render.rect(
           575, 105, (float) ((float) h.prop.get("mp") / (float) h.prop.get("maxmp")) * 176, 20);
       render.end();
       FontUtil.draw(
           sb,
           h.prop.get("hp") + "/" + h.prop.get("maxhp"),
           16,
           blue,
           572
               + 176 / 2
               - FontUtil.getTextWidth(h.prop.get("hp") + "/" + h.prop.get("maxhp"), 20, -7) / 2,
           158,
           400,
           -5,
           0);
       FontUtil.draw(
           sb,
           h.prop.get("mp") + "/" + h.prop.get("maxmp"),
           16,
           blue,
           572
               + 176 / 2
               - FontUtil.getTextWidth(h.prop.get("mp") + "/" + h.prop.get("maxmp"), 20, -7) / 2,
           121,
           400,
           -5,
           0);
       FontUtil.draw(
           sb, "正常", 18, blue, 563 + 176 / 2 - FontUtil.getTextWidth("正常", 18) / 2, 196, 400);
       FontUtil.draw(sb, h.toString(), 18, Color.WHITE, 515, 227, 200);
       if (drawp) {
         add.draw(sb, Gdx.graphics.getDeltaTime());
         drawp = !add.isComplete();
       } else add.reset();
       sb.draw(h.images[1].getRegion(), 810, 97);
     }
     sb.flush();
   }
   if (group.isVisible()) {
     group.draw(batch, 1);
     String tmp = String.valueOf(currentCount);
     tmp = tmp.length() == 1 ? "00" + tmp : tmp.length() == 2 ? "0" + tmp : tmp;
     Image i1 = NumberUtil.get(tmp.substring(0, 1));
     i1.setPosition(390, 275);
     i1.draw(sb);
     Image i2 = NumberUtil.get(tmp.substring(1, 2));
     i2.setPosition(430, 275);
     i2.draw(sb);
     Image i3 = NumberUtil.get(tmp.substring(2, 3));
     i3.setPosition(470, 275);
     i3.draw(sb);
   }
   sb.end();
 }
  @Override
  public void create() {
    spriteBatch = new SpriteBatch();

    effect = new ParticleEffect();
    effect.load(Gdx.files.internal("data/test.p"), Gdx.files.internal("data"));
    effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    // Of course, a ParticleEffect is normally just used, without messing around with its emitters.
    emitters = new Array(effect.getEmitters());
    effect.getEmitters().clear();
    effect.getEmitters().add(emitters.get(0));

    inputProcessor =
        new InputProcessorLW() {
          public boolean touchUp(int x, int y, int pointer, int button) {
            return false;
          }

          public boolean touchDragged(int x, int y, int pointer) {
            effect.setPosition(x, Gdx.graphics.getHeight() - y);
            return false;
          }

          public boolean touchDown(int x, int y, int pointer, int newParam) {
            effect.setPosition(x, Gdx.graphics.getHeight() - y);
            return false;
          }

          public boolean keyUp(int keycode) {
            return false;
          }

          public boolean keyTyped(char character) {
            return false;
          }

          public boolean keyDown(int keycode) {
            ParticleEmitter emitter = emitters.get(emitterIndex);
            if (keycode == Input.Keys.DPAD_UP) particleCount += 5;
            else if (keycode == Input.Keys.DPAD_DOWN) particleCount -= 5;
            else if (keycode == Input.Keys.SPACE) {
              emitterIndex = (emitterIndex + 1) % emitters.size;
              emitter = emitters.get(emitterIndex);
              particleCount =
                  (int)
                      (emitter.getEmission().getHighMax() * emitter.getLife().getHighMax() / 1000f);
            } else return false;
            particleCount = Math.max(0, particleCount);
            if (particleCount > emitter.getMaxParticleCount())
              emitter.setMaxParticleCount(particleCount * 2);
            emitter.getEmission().setHigh(particleCount / emitter.getLife().getHighMax() * 1000);
            effect.getEmitters().clear();
            effect.getEmitters().add(emitter);
            return false;
          }

          @Override
          public boolean touchMoved(int x, int y) {
            return false;
          }

          @Override
          public boolean scrolled(int amount) {
            return false;
          }

          @Override
          public void touchTap(int x, int y) {

            ParticleEmitter emitter = emitters.get(emitterIndex);
            //				if (keycode == Input.Keys.DPAD_UP)
            //					particleCount += 5;
            //				else if (keycode == Input.Keys.DPAD_DOWN)
            //					particleCount -= 5;
            //				else if (keycode == Input.Keys.SPACE) {
            emitterIndex = (emitterIndex + 1) % emitters.size;
            emitter = emitters.get(emitterIndex);
            particleCount =
                (int) (emitter.getEmission().getHighMax() * emitter.getLife().getHighMax() / 1000f);
            //				} else
            //					return false;
            particleCount = Math.max(0, particleCount);
            if (particleCount > emitter.getMaxParticleCount())
              emitter.setMaxParticleCount(particleCount * 2);
            emitter.getEmission().setHigh(particleCount / emitter.getLife().getHighMax() * 1000);
            effect.getEmitters().clear();
            effect.getEmitters().add(emitter);

            effect.setPosition(x, Gdx.graphics.getHeight() - y);
          }

          @Override
          public void touchDrop(int x, int y) {
            // TODO Auto-generated method stub

          }
        };

    Gdx.input.setInputProcessor(inputProcessor);
  }
 @Override
 public void draw(SpriteBatch batch, float parentAlpha) {
   effect.draw(batch, 1 - parentAlpha);
   super.draw(batch, parentAlpha);
 }
 public ParticleEmitter getEmitter() {
   return effect.getEmitters().get(effectPanel.editIndex);
 }
Example #25
0
  public void draw(SpriteBatch batch) {
    super.draw(batch);

    giantEffect.draw(batch, Gdx.graphics.getDeltaTime());
  }
Example #26
0
  public Giant(
      World world,
      RayHandler rh,
      BulletHandler bh,
      Color aColor,
      float rad,
      float critSize,
      float xPos,
      float yPos,
      String particlePath,
      EntityHandler eh,
      float facingDirection,
      float velocity,
      float angularVel,
      boolean isDynamic) {
    super("data/particle-fire.png", aColor, rad);

    bulletHandler = bh;
    criticalRadius = critSize;
    canChangeColor = false;
    canChangeSize = true;
    lightSize = 10 * radius;
    ignoreSize = true;
    ignoreExistence = true;

    originalDirection = facingDirection;
    originalVelocity = velocity;
    angularVelocity = angularVel;

    entityHandler = eh;
    rayHandler = rh;
    originalRadius = rad; // Used for exploding

    BodyDef circleDef = new BodyDef();

    if (isDynamic) circleDef.type = BodyType.DynamicBody;
    else circleDef.type = BodyType.StaticBody;

    circleDef.position.set(xPos, yPos);

    Body circleBody = world.createBody(circleDef);

    CircleShape circleShape = new CircleShape();
    circleShape.setRadius(rad);

    FixtureDef circleFixture = new FixtureDef();
    circleFixture.shape = circleShape;
    circleFixture.density = 1.0f;
    circleFixture.friction = 1.0f;
    circleFixture.restitution = 0.0f;
    circleFixture.filter.categoryBits = LightGameFilters.CATEGORY_ENTITY;
    circleFixture.filter.maskBits = LightGameFilters.MASK_ENTITY;

    circleBody.createFixture(circleFixture);

    // Lights
    ArrayList<Light> blueGiantLights = new ArrayList<Light>();
    PointLight pl = new PointLight(rayHandler, 400, aColor, rad * 10, 0, 0);
    pl.setXray(true);
    pl.attachToBody(circleBody, 0, 0);
    blueGiantLights.add(pl);

    // Set the variables in Entity
    entityBody = circleBody;
    lights = blueGiantLights;

    giantEffect = new ParticleEffect();
    giantEffect.load(Gdx.files.internal(particlePath), Gdx.files.internal("data"));
    giantEffect.setPosition(entityBody.getPosition().x, entityBody.getPosition().y);
    giantEffect.start();
  }
Example #27
0
  public static void load(NanoCat nano) {

    pref = Gdx.app.getPreferences("NanoGameState");

    if (!pref.getBoolean("hdState")) {
      if (nano.getTime() < 15 && nano.getTime() >= 5) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_1_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

      } else if (nano.getTime() < 20 && nano.getTime() >= 15) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_2_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() >= 20) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3_s.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3_s.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      }
    } else if (pref.getBoolean("hdState")) {
      if (nano.getTime() < 15 && nano.getTime() >= 5) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_1.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_1.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() < 20 && nano.getTime() >= 15) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_2.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_2.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else if (nano.getTime() >= 20) {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      } else {
        bgTexture = new Texture(Gdx.files.internal("data/bg_3.png"));
        bgTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bgBackTexture = new Texture(Gdx.files.internal("data/bg_dist_3.png"));
        bgBackTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
      }
    }

    bgBack = new TextureRegion(bgBackTexture, 0, 0, 4096, 580);

    // Particle Stuff

    smoke = new Texture(Gdx.files.internal("data/smoke_particle.png"));
    smokeSprite = new Sprite(smoke);
    smokeEmitter = new ParticleEmitter();
    smokeParticle = new ParticleEffect();
    smokeParticle.load(Gdx.files.internal("data/particlesmoke"), Gdx.files.internal("data"));
    smokeParticle.findEmitter("smoke").getScale().setHigh(50f);

    starEmitter = new ParticleEmitter();
    starParticle = new ParticleEffect();
    starParticle.load(Gdx.files.internal("data/particles"), Gdx.files.internal("data"));
    starParticle.findEmitter("star").getScale().setHigh(5f);
    starParticle.findEmitter("star2").getScale().setHigh(5f);

    //		smokeParticle.getScale().setHigh(5f);

    // End Particle Stuff

    texture = new Texture(Gdx.files.internal("data/nano_region.png"));
    texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

    nanoRun = new TextureAtlas(Gdx.files.internal("data/nanorun.atlas"));
    platform = new TextureAtlas(Gdx.files.internal("data/platform.atlas"));

    catRun1 = nanoRun.findRegion("nanorun0001");
    catRun2 = nanoRun.findRegion("nanorun0005");
    catRun3 = nanoRun.findRegion("nanorun0009");
    catRun4 = nanoRun.findRegion("nanorun0013");
    catRun5 = nanoRun.findRegion("nanorun0017");
    catRun6 = nanoRun.findRegion("nanorun0021");
    catRun7 = nanoRun.findRegion("nanorun0025");
    catRun8 = nanoRun.findRegion("nanorun0029");
    catRun9 = nanoRun.findRegion("nanorun0033");
    catRun10 = nanoRun.findRegion("nanorun0037");
    catRun11 = nanoRun.findRegion("nanorun0041");
    catRun12 = nanoRun.findRegion("nanorun0045");
    catRun13 = nanoRun.findRegion("nanorun0049");
    catRun14 = nanoRun.findRegion("nanorun0053");
    catRun15 = nanoRun.findRegion("nanorun0057");

    catCollide1 = nanoRun.findRegion("nanocollide0080");
    catCollide2 = nanoRun.findRegion("nanocollide0084");
    catCollide3 = nanoRun.findRegion("nanocollide0088");
    catCollide4 = nanoRun.findRegion("nanocollide0092");
    catCollide5 = nanoRun.findRegion("nanocollide0096");
    catCollide6 = nanoRun.findRegion("nanocollide0100");
    catCollide7 = nanoRun.findRegion("nanocollide0104");
    catCollide8 = nanoRun.findRegion("nanocollide0108");

    case0 = platform.findRegion("case0");
    case1 = platform.findRegion("case1");
    case2 = platform.findRegion("case2");
    case3 = platform.findRegion("case3");
    case4 = platform.findRegion("case4");
    case5 = platform.findRegion("case5");
    case6 = platform.findRegion("case6");
    caseDefault = platform.findRegion("default");

    TextureRegion[] catRun = {
      catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun10,
      catRun11, catRun12, catRun13, catRun14, catRun15
    };
    catRunAnim = new Animation(.015f, catRun);
    catRunAnim.setPlayMode(Animation.PlayMode.LOOP);

    TextureRegion[] catJump = {
      catRun1, catRun2, catRun3, catRun4, catRun5, catRun6, catRun7, catRun8, catRun9, catRun9,
      catRun9, catRun9, catRun9, catRun9, catRun9, catRun9
    };
    catJumpAnim = new Animation(.04f, catJump);
    catJumpAnim.setPlayMode(Animation.PlayMode.LOOP);

    TextureRegion[] catCollide = {
      catCollide1,
      catCollide2,
      catCollide3,
      catCollide4,
      catCollide5,
      catCollide6,
      catCollide7,
      catCollide8
    };
    catCollideAnim = new Animation(.02f, catCollide);
    catCollideAnim.setPlayMode(Animation.PlayMode.NORMAL);

    fontFilter = new Texture(Gdx.files.internal("data/roboto_lt.png"));
    fontFilter.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    robotoLt =
        new BitmapFont(
            Gdx.files.internal("data/roboto_lt.fnt"), new TextureRegion(fontFilter), false);
    robotoLt.setScale(.5f, .5f);

    fontFilter2 = new Texture(Gdx.files.internal("data/roboto_blk.png"));
    fontFilter2.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    robotoBlk =
        new BitmapFont(
            Gdx.files.internal("data/roboto_blk.fnt"), new TextureRegion(fontFilter2), false);
    robotoBlk.setScale(.5f, .5f);

    panel = new Texture(Gdx.files.internal("data/panelcolor.png"));
    panel.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    panelSprite = new Sprite(panel, 500, 300);

    fbShare = new Texture(Gdx.files.internal("data/fbshare.png"));
    fbShare.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    fbShareSprite = new Sprite(fbShare, 199, 57);

    menuBack = new Texture(Gdx.files.internal("data/menu_back.png"));
    menuBack.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    menuBackSprite = new Sprite(menuBack, 320, 50);

    collision = Gdx.audio.newSound(Gdx.files.internal("data/audio/collide.wav"));
    milestone = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone.wav"));
    milestone50 = Gdx.audio.newSound(Gdx.files.internal("data/audio/milestone50.wav"));
    jump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump.wav"));
    jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/audio/jump_sound.wav"));
    dblJump = Gdx.audio.newSound(Gdx.files.internal("data/audio/nanojump2.wav"));
    hit = Gdx.audio.newSound(Gdx.files.internal("data/audio/hit.wav"));
    select = Gdx.audio.newSound(Gdx.files.internal("data/audio/select.wav"));
    run = Gdx.audio.newSound(Gdx.files.internal("data/audio/run.wav"));
    highScore = Gdx.audio.newSound(Gdx.files.internal("data/audio/highscore.wav"));

    // Scoring
    score = Gdx.app.getPreferences("NanoCat");

    if (!score.contains("distance")) {
      score.putFloat("distance", 0);
    }

    if (!score.contains("highScore")) {
      score.putFloat("highScore", 0);
    }

    if (!score.contains("totalFall")) {
      score.putInteger("totalFall", 0);
    }
  }
Example #28
0
 @Override
 public void onRemove() {
   super.onRemove();
   particleEffect.setDuration(0);
   introParticleEffect.setDuration(0);
 }
Example #29
0
  public void init() {
    add = new ParticleEffect();
    add.load(
        Gdx.files.internal(Setting.GAME_RES_PARTICLE + "addp.p"),
        Gdx.files.internal(Setting.GAME_RES_PARTICLE));
    add.setPosition(835, 111);

    render = new ShapeRenderer();
    render.setAutoShapeType(true);

    stage =
        new Stage(
            new ScalingViewport(
                Scaling.stretch,
                GameUtil.screen_width,
                GameUtil.screen_height,
                new OrthographicCamera()),
            GameMenuView.stage.getBatch());

    $.add(
            new ImageButton(
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "exit.png"),
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "exitc.png")))
        .setPosition(960, 550)
        .fadeOut()
        .addAction(Actions.parallel(Actions.fadeIn(0.2f), Actions.moveTo(960, 510, 0.1f)))
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
                GameViews.gameview.stackView.disposes();
              }
            })
        .appendTo(stage);

    $.add(
            new ImageButton(
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "min.png"),
                Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_GLOBAL + "minc.png")))
        .setPosition(910, 550)
        .fadeOut()
        .addAction(Actions.parallel(Actions.fadeIn(0.2f), Actions.moveTo(910, 510, 0.1f)))
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                GameViews.gameview.stackView.onkeyDown(Keys.ESCAPE);
                Music.playSE("snd210");
              }
            })
        .appendTo(stage);

    Image bg = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "item_bg.png");
    bg.setColor(1, 1, 1, 0);
    bg.setPosition(160, 28);
    bg.addAction(Actions.fadeIn(0.2f));
    stage.addActor(bg);

    ListStyle style = new ListStyle();
    style.font = FontUtil.generateFont(" ".toCharArray()[0], 22);
    style.selection = Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_EQUIP + "equipsel.png");
    style.fontColorSelected = Color.valueOf("f5e70c");
    elist = new com.rpsg.rpg.system.ui.List<Item>(style);
    elist.onClick(
        new Runnable() {
          @Override
          public void run() {
            item = elist.getSelected();
            Music.playSE("snd210");
          }
        });
    elist.layout();
    pane = new ScrollPane(elist);
    pane.getStyle().vScroll = Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "scrollbar.png");
    pane.getStyle().vScrollKnob =
        Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "scrollbarin.png");
    pane.setForceScroll(false, true);
    pane.layout();

    Table table = new Table();
    table.add(pane);
    table.padRight(20);
    table.setPosition(170, 40);
    table.setSize(270, 390);
    table.getCell(pane).width(table.getWidth()).height(table.getHeight() - 20);
    table.setColor(1, 1, 1, 0);
    table.addAction(Actions.fadeIn(0.2f));
    stage.addActor(table);
    topbarSel = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "topsel.png");
    topbar = new Table();
    topbar.setBackground(Res.getDrawable(Setting.GAME_RES_IMAGE_MENU_ITEM + "topbar.png"));
    topbar.setSize(818, 42);
    topbar.setPosition(160, 455);
    int tmpI = 0, offsetX = 135;
    topbar.add(new TopBar("medicine", tmpI++ * offsetX));
    topbar.add(new TopBar("material", tmpI++ * offsetX));
    topbar.add(new TopBar("cooking", tmpI++ * offsetX));
    topbar.add(new TopBar("equipment", tmpI++ * offsetX));
    topbar.add(new TopBar("spellcard", tmpI++ * offsetX));
    topbar.add(new TopBar("important", tmpI++ * offsetX));
    for (Cell cell : topbar.getCells()) {
      cell.padLeft(50).padRight(34).height(40);
      cell.getActor()
          .addListener(
              new InputListener() {
                public boolean touchDown(
                    InputEvent event, float x, float y, int pointer, int button) {
                  Music.playSE("snd210");
                  return true;
                }
              });
    }

    stage.addActor(topbar);

    generateLists("medicine");

    final Actor mask = new Actor();
    mask.setWidth(GameUtil.screen_width);
    mask.setHeight(GameUtil.screen_height);
    mask.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return false;
          }
        });
    stage.addActor(mask);
    scuse = Res.get(Setting.GAME_RES_IMAGE_MENU_SC + "sc_use.png");
    scuse.loaded =
        new Runnable() {
          @Override
          public void run() {
            scuse.setPosition(
                (int) (GameUtil.screen_width / 2 - scuse.getWidth() / 2),
                (int) (GameUtil.screen_height / 2 - scuse.getHeight() / 2));
          }
        };
    sellist = new com.rpsg.rpg.system.ui.List<ListItem>(style);
    sellist.onDBClick(
        new Runnable() {
          @Override
          public void run() {
            sellist.getSelected().run.run();
          }
        });
    can =
        new Runnable() {
          @Override
          public void run() {
            scuse.visible = false;
            sellist.setVisible(false);
            mask.setVisible(false);
            layer = 0;
          }
        };
    sellist.setPosition(368, 240);
    sellist.setSize(254, 100);
    sellist.layout();

    stage.addActor(
        sellist.onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
              }
            }));

    final Actor mask2 = new Actor();
    mask2.setWidth(GameUtil.screen_width);
    mask2.setHeight(GameUtil.screen_height);
    mask2.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return false;
          }
        });

    elist.onDBClick(
        new Runnable() {
          @Override
          public void run() {
            scuse.visible = true;
            sellist.offsetX2 = 20;
            sellist.getItems().clear();
            if (item.type == Item.TYPE_USEINMAP)
              sellist
                  .getItems()
                  .add(
                      new ListItem("使用")
                          .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "yes.png"))
                          .setRunnable(
                              new Runnable() {
                                @Override
                                public void run() {
                                  scfor.visible = true;
                                  herolist.setVisible(true);
                                  mask2.setVisible(true);
                                  layer = 2;
                                }
                              }));
            if (item.throwable)
              sellist
                  .getItems()
                  .add(
                      new ListItem("丢弃")
                          .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "bin.png"))
                          .setRunnable(
                              new Runnable() {
                                @Override
                                public void run() {
                                  group.setVisible(true);
                                  mask2.setVisible(true);
                                  can.run();
                                  currentCount = 1;
                                  layer = 3;
                                }
                              }));
            sellist
                .getItems()
                .add(
                    new ListItem("取消")
                        .setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "no.png"))
                        .setRunnable(
                            new Runnable() {
                              @Override
                              public void run() {
                                can.run();
                              }
                            }));
            sellist.onDBClick(
                new Runnable() {
                  @Override
                  public void run() {
                    sellist.getSelected().run.run();
                  }
                });
            sellist.setVisible(true);
            sellist.setSelectedIndex(0);
            sellist.setItemHeight(27);
            sellist.padTop = 2;
            mask.setVisible(true);
            layer = 1;
          }
        });

    stage.addActor(mask2);
    scfor = Res.get(Setting.GAME_RES_IMAGE_MENU_ITEM + "selbg.png");
    scfor.setPosition(500, 87);

    herolist = new com.rpsg.rpg.system.ui.List<ListItem>(style);
    herolist.offsetX2 = 20;
    herolist
        .getItems()
        .add(new ListItem("取消").setUserObject(Res.get(Setting.GAME_RES_IMAGE_ICONS + "no.png")));
    for (Hero h : HeroController.heros) {
      herolist.getItems().add(new ListItem(h.name).setUserObject(h));
    }

    herolist
        .onDBClick(
            new Runnable() {
              @Override
              public void run() {}
            })
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                Music.playSE("snd210");
              }
            });
    herolist.setPosition(492, 273);
    herolist.setSize(257, 140);
    herolist.layout();
    stage.addActor(herolist);

    can2 =
        new Runnable() {
          @Override
          public void run() {
            scfor.visible = false;
            herolist.setVisible(false);
            mask2.setVisible(false);
            layer = 1;
          }
        };
    TextButtonStyle butstyle = new TextButtonStyle();
    butstyle.over =
        butstyle.checkedOver = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button_hover.png");
    butstyle.down = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button_active.png");
    butstyle.up = Res.getDrawable(Setting.GAME_RES_IMAGE_GLOBAL + "button.png");
    group = new Group();
    Image tbg = new Image(Setting.GAME_RES_IMAGE_MENU_SC + "throw.png");
    tbg.setPosition(350, 200);
    group.addActor(tbg);
    TextButton button;
    button =
        new TextButton("确定", butstyle)
            .onClick(
                new Runnable() {
                  @Override
                  public void run() {
                    ItemUtil.throwItem(currentBar.name, item, currentCount);
                    AlertUtil.add("丢弃成功。", AlertUtil.Yellow);
                    ItemView.this.generateLists(currentBar.name);
                    item = new TipItem();
                    can3.run();
                  }
                });
    button.setPosition(630, 290);
    button.setSize(100, 50);
    group.addActor(button);
    TextButton button2 =
        new TextButton("取消", butstyle)
            .onClick(
                new Runnable() {
                  @Override
                  public void run() {
                    can3.run();
                  }
                });

    button2.setPosition(630, 225);
    button2.setSize(100, 50);
    group.addActor(button2);
    ImageButton upbutton1 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton1
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 100 <= item.count) currentCount += 100;
              }
            })
        .setPosition(395, 340);
    group.addActor(upbutton1);
    ImageButton upbutton2 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton2
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 10 <= item.count) currentCount += 10;
              }
            })
        .setPosition(435, 340);
    group.addActor(upbutton2);
    ImageButton upbutton3 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "up.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "ups.png"));
    upbutton3
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount + 1 <= item.count) currentCount += 1;
              }
            })
        .setPosition(475, 340);
    group.addActor(upbutton3);
    ImageButton dbutton1 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton1
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 100 >= 1) currentCount -= 100;
              }
            })
        .setPosition(395, 240);
    group.addActor(dbutton1);
    ImageButton dbutton2 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton2
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 10 >= 1) currentCount -= 10;
              }
            })
        .setPosition(435, 240);
    group.addActor(dbutton2);
    ImageButton dbutton3 =
        new ImageButton(
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "down.png"),
            Res.getDrawable(Setting.GAME_RES_IMAGE_NUMBER + "downs.png"));
    dbutton3
        .onClick(
            new Runnable() {
              @Override
              public void run() {
                if (currentCount - 1 >= 1) currentCount -= 1;
              }
            })
        .setPosition(475, 240);
    group.addActor(dbutton3);

    Table buttable = new Table();
    buttable
        .add(
            new TextButton("最大", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        currentCount = item.count == 0 ? 1 : item.count;
                      }
                    }))
        .size(80, 33)
        .row();
    buttable
        .add(
            new TextButton("+1", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (currentCount < item.count) currentCount++;
                      }
                    }))
        .size(80, 35)
        .row();
    buttable
        .add(
            new TextButton("-1", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (currentCount > 1) currentCount--;
                      }
                    }))
        .size(80, 35)
        .row();
    buttable
        .add(
            new TextButton("最小", butstyle, 16)
                .onClick(
                    new Runnable() {
                      @Override
                      public void run() {
                        currentCount = 1;
                      }
                    }))
        .size(80, 33)
        .row();
    for (Cell c : buttable.getCells()) {
      c.padTop(2).padBottom(2);
    }

    buttable.setPosition(575, 300);
    group.addActor(buttable);
    stage.addActor(group);
    for (final Actor a : group.getChildren()) {
      a.addListener(
          new InputListener() {
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
              if (!(a instanceof Image)) Music.playSE("snd210");
              return true;
            }
          });
    }

    can3 =
        new Runnable() {
          @Override
          public void run() {
            group.setVisible(false);
            mask2.setVisible(false);
            can.run();
          }
        };
    can3.run();
    can2.run();
    can.run();
  }
Example #30
0
 @Override
 public void draw(SpriteBatch batch) {
   if (!active) return;
   effect.draw(batch);
 }