Cerberus X Documentation

App Resource Handling

Supported File Formats

This table lists the file formats supported by Cerberus X targets.

You should also specify the file formats your app uses via the App config settings TEXT_FILES, IMAGE_FILES, SOUND_FILES, MUSIC_FILES and BINARY_FILES.

mojo.graphics.LoadImagepng, jpgpngpng, jpg, bmp, gifpng, jpg, bmp, gif, tifpng, jpg
mojo.audio.LoadSoundwav, ogg, mp3, m4awav, oggwav, ogg, mp3, m4awav, mp3, m4a, caf, aiffmp3
mojo.audio.PlayMusicwav, ogg, mp3, m4awav, oggwav, ogg, mp3, m4awav, mp3, m4a, caf, aiffmp3

Resource Paths in Cerberus X

App resources may be stored in many different locations, for example, in an app's data dir, on the local filesystem, or on a remote server.

App Data Directory

The app's data dir is a sub-directory in the directory where your app's main file is stored and has the name AppName.data - e.g. if your main file is stored as myProject/myApp.cxs your data dir is myProject/myApp.data/ and resources can be loaded from there.

Locating Resources

When using functions and methods that open or load resources, you can use any of the following prefixes when specifying resource paths:

Not all prefixes work on all targets and the exact behavior of each prefix is target dependant. For example, android and ios can load images from http:// but not audio, while glfw cannot load from http:// at all. Full support for all prefixes is an ongoing mission!

Also, note that Mojo module load commands will automatically insert a cerberus://data/ prefix before any path that does not already include a prefix. For example, the two following lines are the same:

LoadImage( "myimage.png" )
LoadImage( "cerberus://data/myimage.png" )

Resource Path Prefix Support

FunctionHtml5DesktopAndroidiOSC++ ToolWin8Flash
mojo.app.LoadStringweb, datadata, fileweb, data, filedata, fileNAdata, filedata
mojo.graphics.LoadImageweb, datadata, fileweb, data, fileweb, data, fileNAdata, filedata
mojo.audio.LoadSoundweb, datadata, filedatadata, fileNAdata, filedata
mojo.audio.PlayMusicweb, datadata, filedatadata, fileNAdata, filedata
DataBuffer.Loadweb, datadata,fileweb, data, filedata, filefiledata, filedata

Asset Import

The Import keyword can be used to provide assets to the current project which are not stored in the project data directory. See the resource paths documentation for the definition of the project data directory and how to load resources.

However, if you need access to a file that is not in the data directory, you can tell Cerberus X to include that file in your build and make it visible and accessible for data loading by 'importing' it with it's relative file path. For example:

Import "assets/myfile.png" ' makes assets/myfile.png accessible

Image.Load("myfile.png") ' loads the file