Esempio n. 1
0
  /** This is analog method, result is written to ret. No garbage. */
  public void convertTouchToNodeSpace(MotionEvent event, CGPoint ret) {
    int action = event.getAction();
    int pid = action >> MotionEvent.ACTION_POINTER_ID_SHIFT;
    if (Build.VERSION.SDK_INT >= 5) {
      CCDirector.sharedDirector().convertToGL(Util5.getX(event, pid), Util5.getY(event, pid), ret);
    } else {
      CCDirector.sharedDirector().convertToGL(event.getX(), event.getY(), ret);
    }

    convertToNodeSpace(ret.x, ret.y, ret);
  }
Esempio n. 2
0
  /**
   * converts a UITouch (world coordinates) into a local coordiante. This method is AR (Anchor
   * Relative).
   *
   * @since v0.7.1
   */
  public CGPoint convertTouchToNodeSpaceAR(MotionEvent event) {
    OneClassPool<CGPoint> pool = PoolHolder.getInstance().getCGPointPool();
    CGPoint point = pool.get();

    int action = event.getAction();
    int pid = action >> MotionEvent.ACTION_POINTER_ID_SHIFT;
    if (Build.VERSION.SDK_INT >= 5) {
      CCDirector.sharedDirector()
          .convertToGL(Util5.getX(event, pid), Util5.getY(event, pid), point);
    } else {
      CCDirector.sharedDirector().convertToGL(event.getX(), event.getY(), point);
    }

    float x = point.x, y = point.y;
    pool.free(point);

    return convertToNodeSpaceAR(x, y);
  }