@Override
    public boolean wyKeyDown(KeyEvent event) {
      switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_MENU:
          mHasViewport = !mHasViewport;
          if (mHasViewport) {
            WYSize s = Director.getInstance().getWindowSize();
            mMap.setClipRect(WYRect.make(50, 50, s.width - 100, s.width - 100));
          } else {
            mMap.clearClipRect();
          }
          break;
      }

      return false;
    }
    public MyLayer() {
      Texture2D tex1 = Texture2D.make(R.drawable.ortho_test1);
      tex1.autoRelease();
      Texture2D tex2 = Texture2D.make(R.drawable.ortho_test1_bw);
      tex2.autoRelease();
      mMap = TMXTileMap.make(R.raw.orthogonal_test5, tex1, tex2);
      addChild(mMap);

      // add click feedback sprite
      Texture2D tex = Texture2D.make(R.drawable.blocks);
      mSprite = Sprite.make(tex, ResolutionIndependent.resolve(WYRect.make(0, 0, 32, 32)));
      mSprite.setVisible(false);
      mMap.addChild(mSprite, 10);

      // add a hint label
      WYSize s = Director.getInstance().getWindowSize();
      Label label = Label.make("(Menu)Switch Clip", 16);
      label.setPosition(s.width / 2, s.height - 30);
      addChild(label);

      setTouchEnabled(true);
      setKeyEnabled(true);
      setJavaVirtualMethods(this);
    }
    @Override
    public boolean wyTouchesMoved(MotionEvent event) {
      // remember android event origin is not same as OpenGL
      // you can use Director.getInstance().convertToGL(event.getX(), event.getY()) to convert it to
      // GL coordinate
      float x = event.getX();
      float y = event.getY();
      float deltaX = x - mLastX;
      float deltaY = y - mLastY;
      mLastX = x;
      mLastY = y;

      mMap.translate(deltaX, -deltaY);
      return true;
    }
    @Override
    public boolean wyTouchesBegan(MotionEvent event) {
      TMXLayer layer = mMap.getTMXLayerAt(0);
      WYPoint loc = Director.getInstance().convertToGL(event.getX(), event.getY());
      loc = layer.convertToNodeSpace(loc.x, loc.y);
      WYDimension d = layer.getTileCoordinateAt(loc.x, loc.y);
      WYPoint pos = layer.getPositionAt(d.x, d.y);
      if (d.x != -1) {
        mSprite.setVisible(true);
        mSprite.setPosition(pos.x + layer.getTileWidth() / 2, pos.y + layer.getTileHeight() / 2);
      } else {
        mSprite.setVisible(false);
      }

      mLastX = event.getX();
      mLastY = event.getY();
      return true;
    }