public void init() {
    ServerData.mapSize = 4;
    makeGround();
    list = new ArrayList<MapItemController>();

    MapItemController item = null;

    item = MapItemFactory.makeMapItem(MapItemFactory.CHERRY_PINK);
    list.add(item);
    addChild(item.getImage());
    item.isoMoveTo(0, 0);

    int i;
    for (i = 1002; i <= 1002; i++) {
      item = MapItemFactory.makeMapItem(i);
      list.add(item);
      addChild(item.getImage());
      item.isoMoveTo(0, 0);
      item.getImage().setVisible(false);
    }

    //		item = MapItemFactory.makeMapItem(MapItemFactory.CHERRY_PINK);
    //		list.add(item);
    //		addChild(item.getImage());
    //		item.isoMoveTo(6,  6);
    GameStatus.isMapEditMode = true;

    this.setIsTouchEnabled(true);
  }
  private void touched(CGPoint pt) {
    MapItemController item = null;
    int len = list.size();

    for (int i = 0; i < len; i++) {
      item = list.get(i);
      if (item.checkDown(pt)) {
        currentItem = item;
        break;
      }
    }
    if (currentItem != null) {
      if (GameStatus.isMapEditMode) {
        CGPoint worldConvert = CGPoint.zero();
        CGPoint itempt = currentItem.getImage().getPositionRef();
        this.convertToWorldSpace(itempt.x, itempt.y, worldConvert);
        Log.i("maplayer_touched", "check");
        SceneManager.getInstance().interfaceLayer.showRoundMenu(worldConvert);
      } else {
        // if deco -> show tooltip
        // else if crop -> harvest.
      }
    }
  }
 public boolean ccTouchesBegan(MotionEvent event) {
   Log.i("maplayer", "touch");
   isMoving = false;
   if (event.getPointerCount() > 1) {
     multi1 = CGPoint.make(event.getX(0), event.getY(0));
     multi2 = CGPoint.make(event.getX(1), event.getY(1));
   } else {
     beforePt = CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));
     firstPt = CGPoint.make(beforePt.x, beforePt.y);
     // item check. set selected item.
     if (currentItem != null) {
       CGPoint nodeConvert = this.convertToNodeSpace(beforePt);
       if (currentItem.checkDown(nodeConvert)) {
         isMoving = true;
       }
     }
   }
   return CCTouchDispatcher.kEventHandled;
 }
  public boolean ccTouchesMoved(MotionEvent event) {
    if (event.getPointerCount() > 1) {
      currentItem = null;
      CGPoint current1 = CGPoint.make(event.getX(0), event.getY(0));
      CGPoint current2 = CGPoint.make(event.getX(1), event.getY(1));
      float before = getDistance(multi1, multi2);
      float current = getDistance(current1, current2);
      changeScale(current - before);
      multi1 = current1;
      multi2 = current2;
    } else {

      if (firstPt != null) {
        CGPoint convertedLocation =
            CCDirector.sharedDirector().convertToGL(CGPoint.make(event.getX(), event.getY()));
        CGPoint current = getPosition();
        if (currentItem != null && GameStatus.isShowRoundMenu && isMoving) {
          currentItem.moveBy(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
          SceneManager.getInstance()
              .interfaceLayer
              .moveByRoundMenu(convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
        } else {
          setPosition(
              current.x + (convertedLocation.x - beforePt.x),
              current.y + (convertedLocation.y - beforePt.y));
          if (GameStatus.isShowRoundMenu) {
            SceneManager.getInstance()
                .interfaceLayer
                .moveByRoundMenu(
                    convertedLocation.x - beforePt.x, convertedLocation.y - beforePt.y);
          }
        }
        beforePt = convertedLocation;
      }
    }
    return true;
  }
 public void roundRotateClicked() {
   if (currentItem != null) {
     currentItem.rotate();
   }
 }