shape-polygon-object.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334
  1. .. include:: ../_header.rst
  2. Polygon
  3. =======
  4. You can create `Polygon <https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Polygon.html>`_ object by dropping the **Polygon** block, from the |BlocksView|_, on the scene.
  5. .. image:: ../images/scene-editor-polygon-create-20220623.webp
  6. :alt: Create a polygon.
  7. A polygon is made with points. You can edit the points in the **Polygon section** or with the `Polygon tool <manipulation-tools.html#polygon-tool>`_.
  8. The Polygon section shows the Points field. The points are presented as a string of the X Y pairs of the points, separated by a space.
  9. .. image:: ../images/scene-editor-polygon-section-20220623.webp
  10. :alt: Polygon section.
  11. The Polygon tool (that you can activate with the ``Y`` key) shows the polygon's points in the scene. It allows you:
  12. * Change the position of a point: drag the point with the mouse cursor.
  13. * Delete a point: move the mouse cursor over the point and press the `Delete` key (or double click). When the cursor is over the point, it is painted in red color.
  14. .. image:: ../images/scene-editor-polygon-edit-points-20220623.webp
  15. :alt: Move polygon point.
  16. * Add a new point: move the mouse cursor over a line. It shows a white handler under the cursor, you can drag it for creating a new point.
  17. .. image:: ../images/scene-editor-polygon-add-point-20220623.webp
  18. :alt: Add new point.
  19. .. image:: ../images/scene-editor-polygon-add-point-2-20220623.webp
  20. :alt: Add new point.
  21. The `Polygon <https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Polygon.html>`_ code is generated by the |SceneCompiler|_ using the `polygon object factory <https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.GameObjectFactory.html#polygon__anchor>`_:
  22. .. code::
  23. const polygon = this.add.polygon(10, 10, "0 0 20 70 100 100 80 20");