示例#1
0
 // --------------------------------------------------------------------------
 // CHANGE LISTENERS:
 // --------------------------------------------------------------------------
 public void onChange(BoardModel board) {
   for (int i = 0; i < board.getRowsOnBoard(); i++) {
     for (int j = 0; j < board.getColsOnBoard(); j++) {
       TileModel square = tiles.get(i).get(j);
       square.setTileState(board.getTileState(i, j));
     }
   }
 }
示例#2
0
 public void update(float dt) {
   super.update(dt);
   if (!doneInitializing) return;
   for (int i = 0; i < board.getRowsOnBoard(); i++) {
     for (int j = 0; j < board.getColsOnBoard(); j++) {
       tiles.get(i).get(j).update(dt);
     }
   }
 }
示例#3
0
 public void draw(Canvas canvas) {
   if (canvas == null) return;
   canvas.drawColor(Color.rgb(151, 177, 174));
   if (!doneInitializing || canvas == null) return;
   for (int i = 0; i < board.getRowsOnBoard(); i++) {
     for (int j = 0; j < board.getColsOnBoard(); j++) {
       tiles.get(i).get(j).draw(canvas);
     }
   }
 }
示例#4
0
  public boolean onTouchDown(MotionEvent touch) {
    int action = touch.getAction();
    int x = 0;
    int y = 0;
    switch (action & MotionEvent.ACTION_MASK) {
      case MotionEvent.ACTION_DOWN:
        y = (int) touch.getY();
        x = (int) touch.getX();

        int col = x / tileSize;
        int row = y / tileSize;
        board.changeTileState(row, col);
        isOnClick = true;
        break;

        // DOES NOT DETECT MOTION... ONLY TOUCH DOWN
      case MotionEvent.ACTION_MOVE:
        if (isOnClick
            && (Math.abs(x - touch.getX()) > SCROLL_THRESHOLD
                || Math.abs(y - touch.getY()) > SCROLL_THRESHOLD)) {
          // System.out.println("movement detected");
          isOnClick = false;
        }
        break;
    }
    return true;
  }