working-with-parent-objects.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. include:: ../_header.rst
  2. Working with parent objects
  3. ---------------------------
  4. In Phaser_, only two type of scene objects can be used as a "container" or a "parent" of other objects: the `Container <./container-object.html>`_, and the `Layer <./layer-object.html>`_ objects.
  5. In the next section you can learn about operations common to both type of objects.
  6. Parent context menu
  7. ~~~~~~~~~~~~~~~~~~~
  8. The **Parent** sub-menu of the scene context menu shows the commands you can apply to containers and layers. Many of those commands are compatible with both types:
  9. .. image:: ../images/parent-context-menu--07082021.webp
  10. :alt: The Parent context menu.
  11. Moving an object to a parent
  12. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  13. You can move an object to a new parent. The command **Move To Parent** opens the **Parent** dialog. This dialog shows all the available parents for the object (including the scene) and you can select the new parent.
  14. The command can be executed by pressing the ``Shift+P`` keys or selecting the **Move To Parent** option in the context menu.
  15. .. image:: ../images/scene-editor-move-to-container-07082021.webp
  16. :alt: Move object to parent.
  17. Breaking a parent
  18. ~~~~~~~~~~~~~~~~~
  19. The **Break Parent** command removes a Container or Layer, but keeps its children. The children are added to the parent of the parent, and their preserve the same absolute position.
  20. You can execute the command by pressing the ``Shift+B`` keys or selecting the **Break Parent** option of the `Parent context menu`_.
  21. Selecting the parent of an object
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. The **Select Parent** command selects the parent of an object. To execute the command press the ``P`` key or click on the **Select Parent** option of the `Parent context menu`_.
  24. Selecting the children of an object
  25. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. The **Select Children** command selects the children of a container or a layer. To execute this command, press the ``N`` key or click on the **Select Children** option in the `Parent context menu`_.
  27. Changing the rendering order of children
  28. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. You can change the rendering order of an object. The context menu shows the **Edit** |-| **Move** commands, to move the objects in different depth directions:
  30. .. image:: ../images/scene-editor-display-list-move-objects-20230627.webp
  31. :alt: Changing the rendering order of objects.