private Image makeLibGDXLogo(TextureAtlas atlas) {
   Image libGdxLogo = new Image(atlas.findRegion("powered-by-libgdx"));
   libGdxLogo.getColor().a = 0f;
   libGdxLogo.addAction(Actions.fadeIn(0.125f));
   libGdxLogo.setY(Display.devicePixel(5));
   libGdxLogo.setX(Display.devicePixel(5));
   libGdxLogo.addListener(
       new VibrateClickListener() {
         @Override
         public void onClick(InputEvent event, float x, float y) {
           Platform.getBrowserUtil().launchWebBrowser("http://libgdx.badlogicgames.com");
         }
       });
   return libGdxLogo;
 }
 private Image makeHappyDroidsLogo(TextureAtlas atlas) {
   Image happyDroidsLogo = new Image(atlas.findRegion("happy-droids-logo"));
   happyDroidsLogo.getColor().a = 0f;
   happyDroidsLogo.addAction(Actions.fadeIn(0.125f));
   happyDroidsLogo.setX(
       getStage().getWidth() - happyDroidsLogo.getWidth() - Display.devicePixel(5));
   happyDroidsLogo.setY(Display.devicePixel(5));
   happyDroidsLogo.addListener(
       new VibrateClickListener() {
         @Override
         public void onClick(InputEvent event, float x, float y) {
           Platform.getBrowserUtil().launchWebBrowser(TowerConsts.HAPPYDROIDS_URI);
         }
       });
   return happyDroidsLogo;
 }
Пример #3
0
  @Override
  public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    Gdx.input.setInputProcessor(stage);

    // listener for play image
    playAgain.addListener(
        new InputListener() {

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
          }

          @Override
          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            // if its in that y region
            if (356 <= y && y <= 414 && first) {

              // if yes
              if (54 <= x && x <= 173) {
                game.setScreen(gameScreen);
                first = false;
              }

              // if no
              if (213 <= x && x <= 302) {
                game.setScreen(introScreen);
                first = false;
              }
            }
          }
        });

    stage.addActor(gameOver);
    stage.addActor(playAgain);

    stage.act(delta);
    batch.begin();
    stage.draw();
    batch.end();
  }
Пример #4
0
  @Override
  public void create() {
    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);

    stage = new Stage();

    float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2;
    for (int i = 0; i < NUM_GROUPS; i++) {
      Group group = new Group();
      group.setX((float) Math.random() * (stage.getWidth() - NUM_SPRITES * (32 + SPACING)));
      group.setY((float) Math.random() * (stage.getHeight() - NUM_SPRITES * (32 + SPACING)));
      group.setOrigin(loc, loc);

      fillGroup(group, texture);
      stage.addActor(group);
    }

    uiTexture = new Texture(Gdx.files.internal("data/ui.png"));
    uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    ui = new Stage();

    Image blend = new Image(new TextureRegion(uiTexture, 0, 0, 64, 32));
    blend.setAlign(Align.center);
    blend.setScaling(Scaling.none);
    blend.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            if (stage.getSpriteBatch().isBlendingEnabled())
              stage.getSpriteBatch().disableBlending();
            else stage.getSpriteBatch().enableBlending();
            return true;
          }
        });
    blend.setY(ui.getHeight() - 64);

    Image rotate = new Image(new TextureRegion(uiTexture, 64, 0, 64, 32));
    rotate.setAlign(Align.center);
    rotate.setScaling(Scaling.none);
    rotate.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            rotateSprites = !rotateSprites;
            return true;
          }
        });
    rotate.setPosition(64, blend.getY());

    Image scale = new Image(new TextureRegion(uiTexture, 64, 32, 64, 32));
    scale.setAlign(Align.center);
    scale.setScaling(Scaling.none);
    scale.addListener(
        new InputListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            scaleSprites = !scaleSprites;
            return true;
          }
        });
    scale.setPosition(128, blend.getY());

    ui.addActor(blend);
    ui.addActor(rotate);
    ui.addActor(scale);

    fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE));
    fps.setPosition(10, 30);
    fps.setColor(0, 1, 0, 1);
    ui.addActor(fps);

    renderer = new ShapeRenderer();
    Gdx.input.setInputProcessor(this);
  }
Пример #5
0
  public void initView() {
    clear();
    float currPos = 0;
    for (int i = 0; i < tabs.size(); i++) {
      boolean isSelected = false;
      if (i == selectedTabIndex) isSelected = true;
      String imgName = "tab";
      if (isSelected) {
        imgName = "tabS";
      }
      Image img = new Image(s.textureManager.getEditorAsset(imgName));
      img.setX(currPos);
      img.setY(0);

      Label lbl = new Label(tabs.get(i), s.textureManager.editorSkin);
      lbl.setX(currPos + 6);
      lbl.setY(2);
      lbl.setTouchable(Touchable.disabled);

      img.setScaleX(lbl.getWidth() + 12);
      currPos += lbl.getWidth() + 12;

      addActor(img);
      addActor(lbl);

      Image sep = new Image(s.textureManager.getEditorAsset("tabSep"));
      sep.setX(img.getX() + img.getScaleX());
      addActor(sep);
      currPos += 1;

      if (isSelected) {
        lbl.setColor(1, 1, 1, 1);
      } else {
        lbl.setColor(1, 1, 1, 0.65f);
      }

      final int currIndex = i;

      img.addListener(
          new ClickListener() {
            public void clicked(InputEvent event, float x, float y) {
              selectedTabIndex = currIndex;
              initView();
              if (tabEventListener != null) {
                tabEventListener.tabOpened(currIndex);
              }
            }
          });

      setHeight(img.getHeight());
    }

    float currWidth = currPos;
    if (getWidth() > currWidth) {
      float diff = getWidth() - currWidth;
      Image rest = new Image(s.textureManager.getEditorAsset("tab"));
      rest.setX(currPos);
      rest.setScaleX(diff);
      addActor(rest);
    }
  }
  public void initGroup() {
    // TODO Auto-generated method stub
    setWidth(Constant.MAP_UNIT_SIZE_WIDTH * 2);
    setHeight(Constant.MAP_UNIT_SIZE_HEIGHT);

    switch (id + 1) {
      case 1:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_1_RANGE;
        break;
      case 2:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_2_RANGE;
        break;
      case 3:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_3_RANGE;
        break;
      case 4:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_4_RANGE;
        break;
      case 5:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_5_RANGE;
        break;
      case 6:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_6_RANGE;
        break;
      case 7:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_7_RANGE;
        break;
      case 8:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_8_RANGE;
        break;
      case 9:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_9_RANGE;
        break;
      case 10:
        tower = new Image(Assets.shared().tower1_Animation_Up.keyFrames[0]);
        range = Constant.TOWER_10_RANGE;
        break;
      default:
        break;
    }
    tower.setPosition(Constant.MAP_UNIT_SIZE_WIDTH / 2 - tower.getWidth() / 2, 0);
    addActor(tower);

    ok = new Image(Assets.shared().button_ok);
    ok.setWidth(Constant.MAP_UNIT_SIZE_WIDTH);
    ok.setHeight(Constant.MAP_UNIT_SIZE_HEIGHT);
    ok.setColor(Color.GREEN);
    ok.setPosition(getWidth() / 2, 0);
    addActor(ok);

    ok_press = new Image(Assets.shared().button_ok_click);
    ok_press.setWidth(Constant.MAP_UNIT_SIZE_WIDTH);
    ok_press.setHeight(Constant.MAP_UNIT_SIZE_HEIGHT);
    ok_press.setColor(Color.GREEN);
    ok_press.setPosition(getWidth() / 2, 0);
    ok_press.setVisible(false);
    addActor(ok_press);

    ok.addListener(
        new ClickListener() {
          @Override
          public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub
            if (screen.world.getTowerCoin(id + 1) <= screen.world.coin) {
              screen.world.coin -= screen.world.getTowerCoin(id + 1);
              screen.world.addNewTower(id + 1, screen.pos, 4);
              for (int i = 0; i < screen.towerButton.length; i++) {
                if (screen.towerButton[i].getX() == getX()
                    && screen.towerButton[i].getY() == getY()) {
                  screen.towerButton[i].isVisible = false;
                }
              }

              for (int j = 0; j < screen.world.activeTower.size; j++) {
                if ((screen.world.activeTower.get(j).getPosition().x
                            - screen.world.activeTower.get(j).xPlus)
                        == getX()
                    && (screen.world.activeTower.get(j).getPosition().y
                            - screen.world.activeTower.get(j).yPlus)
                        == getY()) {
                  screen.radar = true;
                  screen.towerPos = j;
                  break;
                }
              }
              setVisible(false);
              screen.towerGroup.setVisible(false);
            } else {
              // not enough gold
              screen.dialog.setInfo(Constant.not_money_enough);
              screen.dialog.setVisible(true);
            }

            ok.setVisible(true);
            ok_press.setVisible(false);
            super.touchUp(event, x, y, pointer, button);
          }

          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // TODO Auto-generated method stub
            ok.setVisible(false);
            ok_press.setVisible(true);
            return super.touchDown(event, x, y, pointer, button);
          }
        });
  }
Пример #7
0
  public void create() {
    WIDTH = Gdx.graphics.getWidth();
    HEIGHT = Gdx.graphics.getHeight();

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

    Table table = new Table();
    table.setFillParent(true);
    table.setSize(WIDTH, HEIGHT);

    ipTextField = new TextField("lodow.net", skin);
    portTextField = new TextField("4242", skin);

    Label ipLabel = new Label("Ip   : ", skin);
    Label portLabel = new Label("port : ", skin);

    connectionButton = new TextButton("Connect", skin);
    connectionButton.setDisabled(true);
    connectionButton.addListener(new ConnectListener(CONNECT_BUTTON_ID));

    background = new Group();
    background.setBounds(0, 0, WIDTH, HEIGHT);
    background.addActor(new Image(new Texture(Gdx.files.internal("data/mainMenu/zappy_main.png"))));

    Texture cross = new Texture(Gdx.files.internal("data/mainMenu/remove_cross.png"));

    Image cross_ip = new Image(cross);
    cross_ip.addListener(
        new ClickListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            ipTextField.setText("");
            return true;
          }
        });

    Image cross_port = new Image(cross);
    cross_port.addListener(
        new ClickListener() {
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            portTextField.setText("");
            return true;
          }
        });

    table.add(ipLabel).padBottom(20);
    table.add(ipTextField).width(WIDTH / 4).padBottom(20).padRight(20);
    table.add(cross_ip).padBottom(20);
    table.row();
    table.add(portLabel).padBottom(20);
    table.add(portTextField).width(WIDTH / 4).padBottom(40).padRight(20);
    table.add(cross_port).padBottom(30);
    table.row();
    table.add(connectionButton).colspan(5).width(WIDTH / 4);
    table.left().bottom().padBottom(150);

    stage.addActor(background);
    stage.addActor(table);

    batch = new SpriteBatch();

    Gdx.input.setInputProcessor(stage);

    Assets.menuMusic.play();
  }
Пример #8
0
  public HandGroup(GameEventNotifier notifier) {
    super(notifier);

    cards = new Group();
    cards.setBounds(0, 0, UIConstants.WORLD_WIDTH, UIConstants.WORLD_HEIGHT / 2);

    addActor(cards);

    // set up the images and buttons for the zoom menu
    selectButton = new Image(selectTexture);
    selectButton.setScale(1.5f);
    selectButton.setPosition(220, 700);
    cancelButton = new Image(cancelTexture);
    cancelButton.setScale(1.5f);
    cancelButton.setPosition(220, 100);
    cancelButton.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            // return the zoomed card
            unzoom();
            return true;
          }
        });
    nextCardImage = new Image(arrowTexture);
    nextCardImage.setScale(2f);
    nextCardImage.setPosition(1200, 300);
    nextCardImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            changeZoomedCard(1);
            return true;
          }
        });

    previousCardImage = new Image(arrowTexture);
    previousCardImage.rotateBy(180);
    previousCardImage.setScale(2f);
    previousCardImage.setPosition(500, 400);
    previousCardImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            changeZoomedCard(-1);
            return true;
          }
        });
    rotateImage = new Image(rotateTexture);
    rotateImage.setScale(0.5f);
    rotateImage.setPosition(350, 500);
    rotateImage.addListener(
        new InputListener() {
          @Override
          public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            zoomCard.rotate();
            return true;
          }
        });
    zoomGroup = new Group();
    zoomGroup.addActor(selectButton);
    zoomGroup.addActor(cancelButton);
    zoomGroup.addActor(nextCardImage);
    zoomGroup.addActor(previousCardImage);
    zoomGroup.addActor(rotateImage);
    zoomGroup.setTouchable(Touchable.disabled);
    zoomGroup.setVisible(false);

    addActor(zoomGroup);
  }