input-hit-area-rectangle.rst 909 B

123456789101112131415161718192021222324
  1. .. include:: ../_header.rst
  2. Rectangle Hit Area
  3. ~~~~~~~~~~~~~~~~~~
  4. To set a rectangular hit are on the object, select the ``RECTANGLE`` option in the **Shape** parameter of the **Hit Area** section. It enables the **Hit Area (Rectangle)** section where you can set the position and size of the area:
  5. .. image:: ../images/scene-editor-input-hit-area-rectangle-20230517.webp
  6. :alt: Enable rectangle hit area
  7. Also, you can change the values with the **Edit Hit Area** tool (``I``):
  8. .. image:: ../images/scene-editor-input-hit-area-rectangle-tool-20230517.webp
  9. :alt: Changes rectangular hit area with the tool.
  10. When you create a rectangle hit area, the scene compiler generates a code like this:
  11. .. code::
  12. // eye
  13. const eye = this.add.image(369, 277, "lance-overdose-loader-eye");
  14. eye.setInteractive(
  15. new Phaser.Geom.Rectangle(17, 16, 90, 80),
  16. Phaser.Geom.Rectangle.Contains);