コード例 #1
0
ファイル: ChessBoard.java プロジェクト: wertalp/BattleShip_V2
  public CellButton[] getallcells() {
    int l = 0;
    liCellBut = new CellButton[board.getChildCount()];
    for (int i = 0; i <= board.getChildCount(); i++) {
      View tmpView = (View) board.getChildAt(i);
      // Toast.makeText(getActivity(),tmpView.getClass().getName(),Toast.LENGTH_SHORT).show();
      if (tmpView instanceof CellButton) {

        // Toast.makeText(getActivity(),"CellButt",Toast.LENGTH_SHORT).show();
        liCellBut[l] = (CellButton) tmpView;
        l++;
      }
    }

    return liCellBut;
  }
コード例 #2
0
  public void playAgain(View view) {
    winningLayout.setTranslationX(-1000f);
    player = 0;
    for (int i = 0; i < 9; i++) {
      spots[i] = 2;
    }
    gameIsActive = true;
    GridLayout gridLayout = (GridLayout) findViewById(R.id.grid);
    for (int i = 0; i < gridLayout.getChildCount(); i++) {

      ((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
    }
  }
コード例 #3
0
ファイル: MainActivity.java プロジェクト: Ronaldoh1/Connect3
  public void PlayAgain(View view) {

    LinearLayout layout = (LinearLayout) findViewById(R.id.winnerlayout);

    layout.setVisibility(view.INVISIBLE);
    // this.gameState = {2,2,2,2,2,2,2,2,2};

    // 0 = Yellow and 1 = Red;
    activePlayer = 0;
    // 2 means unplayed.

    for (int i = 0; i < gameState.length; i++) {
      gameState[i] = 2;
    }

    // reset the state of the images
    GridLayout gridLayout = (GridLayout) findViewById(R.id.gridLayout);

    for (int i = 0; i < gridLayout.getChildCount(); i++) {

      ((ImageView) gridLayout.getChildAt(i)).setImageResource(0);
    }
  }