Exemplo n.º 1
0
  /** Internal function for helping to update the cursor graphic and world coordinates. */
  protected void updateCursor() {
    Pointer o = _pointers.get(0);

    // actually position the flixel mouse cursor graphic
    if (_cursor != null) {
      _cursor.x = o.screenPosition.x;
      _cursor.y = o.screenPosition.y;
    }

    // update the x, y, screenX, and screenY variables based on the default
    // camera.
    // This is basically a combination of getWorldPosition() and
    // getScreenPosition()
    FlxCamera camera = FlxG.camera;
    screenX =
        (int) ((o.screenPosition.x - camera.x) / (camera.getZoom() * camera._screenScaleFactorX));
    screenY =
        (int) ((o.screenPosition.y - camera.y) / (camera.getZoom() * camera._screenScaleFactorY));
    x = screenX + camera.scroll.x;
    y = screenY + camera.scroll.y;
  }
Exemplo n.º 2
0
  /**
   * Fetch the screen position of the specified pointer on any given camera.
   *
   * @param Pointer The pointer id.
   * @param Camera If unspecified, first/main global camera is used instead.
   * @param Point An existing point object to store the results (if you don't want a new one
   *     created).
   * @return The pointer's location in screen space.
   */
  public FlxPoint getScreenPosition(int Pointer, FlxCamera Camera, FlxPoint Point) {
    if (Camera == null) Camera = FlxG.camera;
    if (Point == null) Point = new FlxPoint();

    if (Pointer >= _pointers.size) return Point;

    Pointer o = _pointers.get(Pointer);

    Point.x = (o.screenPosition.x - Camera.x) / (Camera.getZoom() * Camera._screenScaleFactorX);
    Point.y = (o.screenPosition.y - Camera.y) / (Camera.getZoom() * Camera._screenScaleFactorY);

    return Point;
  }