-
Notifications
You must be signed in to change notification settings - Fork 4
Settings
Greg Rogers edited this page Jan 5, 2020
·
4 revisions
One of the most useful parts of the ERA engine is Settings support. The Settings library allows you to declare settings that can be set by the user and persisted via the LocalStorage API.
The ERA Engine has its own set of settings:
debug: true
movement_deadzone: 0.15
mouse_sensitivity: 50
shaders: true
volume: 50
In order to define your own settings, you'll need to create a settings file:
{
"your_setting": {
"value": true,
},
"difficulty": {
"value": 9000,
}
}
If your user wants to change a settings value, call:
Settings.set('volume', 10);
This will update the persisted value in local storage as well as propagate a SettingsEvent
.
In order to access the settings values, simply call:
Settings.get('volume');
Be sure to call this every time the value is used rather than storing it in a field. Otherwise, you won't be reading the updated settings value.