Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 3
0
  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);
    }
  }