Skip to main content Skip to docs navigation

Document not reviewed yet, might be outdated. Please, let us know if you find something invalid here.
On this page

KorGE uses the Virtual File Systems from Korio to load resources from different sources, and its most basic resources are Bitmaps and Sounds. But it can also load bitmap fonts, tiled maps, etc.

KR

Since KorGE 4.0.3, there is a new autogenerated class called KR. This is similar to Android R, and provides a type-safe way of accessing resources. It exposes all the files in the resources folder, and provides reading shortcuts for images and sounds. In the case of folders ended with .atlas it generates automatically an optimized atlas of the images, and provides a way to access them.

KorGE IntelliJ plugin will also display previews for files and atlases:

You can see it in action in the KorGE youtube channel with the KorGE Chess tutorial.

resourcesVfs

KorIO offers a resourcesVfs global property that holds a Virtual File System that include the files from src/commonMain/resources in all the targets.

ResourcesRoot

With the injector, or as part of the Scene class, you have access to a ResourcesRoot instance. It is a MoutableVfs, where the resourcesVfs is mounted at /. This allows you to load resources from different sources like a cache folder, or a base URL.

Resources

KorGE supports directly or indirectly several kind of resources.

Bitmaps

You can read bitmaps with:

resourcesVfs["relative/path/to/image.png"].readBitmap()

All the targets support at least PNG and JPEG bitmap loading.

Sound and Music

You can read sound files with:

resourcesVfs["relative/path/to/sound.mp3"].readSound()

All targets support WAV and MP3.

Was this article useful?