Пример #1
0
  public void setNextPosition() {
    if (mMovableMaskQueue.size() == 0) return;

    Iterator<MovableMask> it = mMovableMaskQueue.iterator();
    while (it.hasNext()) {
      MovableMask mask = it.next();
      int x = mask.getCenterX();
      int y = mask.getCenterY();
      int step = mask.getStep();
      int direction = mask.getDirection();
      switch (direction) {
        case Utils.NORTH:
          Utils.log(TAG, "moving north");
          mask.setCenter(x, y - step);
          break;
        case Utils.SOUTH:
          Utils.log(TAG, "moving south");
          mask.setCenter(x, y + step);
          break;
        case Utils.WEST:
          Utils.log(TAG, "moving west");
          mask.setCenter(x - step, y);
          break;
        case Utils.EAST:
          Utils.log(TAG, "moving east");
          mask.setCenter(x + step, y);
          break;
        default:
          break;
      }
      // Utils.log(TAG, "get next position,x:" + x + ",y" + y);

    }
  }
Пример #2
0
  public void renderScreen() {
    if (mMovableMaskQueue.size() == 0) {
      if (mMaskType == MOVABLE_MASK) {
        mScreenView.removeAllViews();
      }
      return;
    }

    mScreenView.removeAllViews();
    Iterator<MovableMask> it = mMovableMaskQueue.iterator();
    while (it.hasNext()) {
      MovableMask mask = it.next();
      Rect rect = mask.getRect();
      mScreenView.addView(mask);
      mask.layout(rect.left, rect.top, rect.right, rect.bottom);
    }
  }
Пример #3
0
  public boolean addMovableMask(MovableMask mask) {
    if (mask == null) {
      Utils.log(TAG, "mask is null,return");
      return false;
    }

    if (mMovableMaskQueue.size() == MAX_MOVABLE_MASKS) {
      mMovableMaskQueue.remove();
    }

    Utils.log(TAG, "add a movable mask");
    mMovableMaskQueue.add(mask);
    mScreenView.addView(mask);
    // TODO
    Message msg = new Message();
    msg.what = MSG_KILL_MASK;
    msg.obj = mask;
    mHandler.sendMessageDelayed(msg, mask.getLife());
    Rect rect = mask.getRect();
    mask.layout(rect.left, rect.top, rect.right, rect.bottom);
    return true;
  }