-
Notifications
You must be signed in to change notification settings - Fork 6
Configuration files
If you want to store your levels or settings in a file, you have multiple options to grab them. All you need is to use the getFile()
on your assetpack, which returns the file content as String.
Let's say you have this settings.xml in your assetpack.
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<game>
<name>My Game</name>
<version>3.1</version>
</game>
</settings>
Then you can access the info like this:
var myXML = new Fast(Xml.parse(pack.getFile("settings.xml").toString()).firstElement());
trace(myXML.node.game.node.name.innerData); // output : My Game
trace(myXML.node.game.node.version.innerData); // output : 3.1
Let's say you have this settings.json in your assetpack.
{
"settings": {
"game": {
"name": "My Game",
"version": 3.1
}
}
}
Then you can access the info like this:
var myJson:Dynamic = Json.parse(pack.getFile("settings.json").toString());
trace(myJson.settings.game.name); // output : My Game
trace(myJson.settings.game.version); // output : 3.1
Flambe has a .ini file parser. Let's say you have this settings.ini in your assetpack.
[game]
name="My Game"
version=3.1
Then you can access the info like this. A path is a section and key name separated by a dot. A path without a dot is assumed to be in the main section.
var myConfig:MessageBundle = MessageBundle.parse(pack.getFile("settings.ini").toString());
trace(myConfig.get("game.name")); // output : My Game
trace(myConfig.get("game.version")); // output : 3.1
Want multi-language configuration? Read Multi-language assets
Documentation guide for Flambe - Targeted to version 4.0+
Flambe | Installation | Demo projects | Showcase | API Reference | Forum
Flambe is MIT licensed and available for free. Feel free to contribute!
- Home / Installation
- Entity / Components
- Core
- Assets
- Publish your game
- Other
- Editors
- Plugins, tools, extensions
- Help
- More Flambe