index.rst 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. .. include:: ../_header.rst
  2. .. highlight:: javascript
  3. Asset Pack Editor
  4. =================
  5. .. toctree::
  6. create-asset-pack-file
  7. asset-pack-file
  8. editor-content-layout
  9. add-file
  10. organizing-the-assets
  11. outline-view
  12. inspector-view
  13. In a Phaser_ game, you load the files using the methods of the `Phaser.Loader.LoaderPlugin <https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html>`_ class. This is how you can `load a sprite-sheet <https://photonstorm.github.io/phaser3-docs/Phaser.Loader.LoaderPlugin.html#spritesheet__anchor>`_ file:
  14. .. highlight:: javascript
  15. .. code::
  16. this.load.spritesheet('bot', 'images/robot.png', { frameWidth: 32, frameHeight: 38 });
  17. You pass a key (``'bot'``) to identify the file in the `game cache <https://photonstorm.github.io/phaser3-docs/Phaser.Cache.CacheManager.html>`_, the URL of the file (``'images/robot.png'``) and a sprite-sheet configuration object, with other information like the frame size.
  18. Or you can load the file by passing a single argument, a `SpriteSheetFileConfig <https://photonstorm.github.io/phaser3-docs/Phaser.Types.Loader.FileTypes.html#.SpriteSheetFileConfig__anchor>`_ configuration object:
  19. .. code::
  20. this.load.spritesheet({
  21. key: 'bot',
  22. url: 'images/robot.png',
  23. frameConfig: {
  24. frameWidth: 32,
  25. frameHeight: 38
  26. }
  27. });
  28. Every file type can be loaded using its configuration object, that is just a JSON object. Following this logic, Phaser_ has a special type of files that contains the configurations of other files: the |AssetPackFile|_.
  29. You can load an |AssetPackFile|_ using the ``pack(...)`` method of the loader:
  30. .. code::
  31. this.load.pack("level1", "assets/pack.json");
  32. The |AssetPackEditor| allows you to edit an |AssetPackFile|_, making it very easy to load the assets in your game. Instead of spending precious time writing the JSON file by hand, with the |AssetPackEditor|_ you can load your assets with a visual tool and smart operations.
  33. .. image:: ../images/asset-pack-editor-overview-01012022.webp
  34. :alt: Asset Pack Editor.
  35. The |AssetPackFile|_ is relevant in the IDE for two main reasons:
  36. * It is a Phaser_ built-in format. This means you can create an |AssetPackFile|_ with |PhaserEditor|_ and use it in any Phaser_ project, even if you are using another IDE.
  37. * The |SceneEditor|_ and eventually other tools provided by the IDE are based on Phaser_. This means that the IDE can reuse the |AssetPackFile|_ information to load the assets into its internal tools.