Using Assets
Assets represent files that get loaded before the game starts. These can include audio, images, and custom assets such as level data.
Using Pearl's asset system saves you from writing custom code to load assets, and provides a simple UI for accessing your assets within your game's components.
Pearl's asset system does not handle the problem of bundling assets with your game, but is very easy to use with a bundler like Webpack, as you'll see below.
TODO: Explain Webpack require()
a lil bit
Preloading Assets
Pearl includes a special preloader for loading assets before starting the game.
Now, within a component, we can access and use swordImage
. For example, here we create a Sprite
with it:
Custom Assets
You can define custom assets to load by extending the Asset
class. For example, to load level data from an external file as a string, we could define an asset:
Last updated