mirror of
https://github.com/wassname/metacar.git
synced 2026-09-09 11:26:47 +08:00
20 lines
635 B
JavaScript
20 lines
635 B
JavaScript
|
|
// Get the url of the desired level
|
|
let levelToLoad = metacar.level.level0;
|
|
|
|
// If a level is avaiable in the storage, load this level instead.
|
|
var levelObject = localStorage.getItem('mylevel.json');
|
|
if (levelObject){
|
|
levelToLoad = JSON.parse(levelObject);
|
|
}
|
|
|
|
// Create the editor (canvasID, levelUrl)
|
|
var editor = new metacar.editor("editor", levelToLoad);
|
|
editor.load().then(() => {
|
|
editor.addEvent("save", (content) => {
|
|
// Put the object into storage
|
|
localStorage.setItem('mylevel.json', JSON.stringify(content));
|
|
window.open("/test_editor.html");
|
|
|
|
}, {download: true, name: "level.json"});
|
|
}); |