Hello everybody,
I’ve got a simple demo project, where i want to create a json level, load this json level and then modify entries in this level.
Here is the Code of the main.qml:
import VPlay 1.0
import QtQuick 1.1
import Box2D 1.0
GameWindow {
id: window
Scene
{
id:mainScene
anchors.fill: parent
EntityManager
{
id:entityManager
}
LevelEditor
{
id:levelEditor
applicationJSONLevelsDirectory: "levels/"
entityManagerItem: entityManager
}
SimpleButton
{
anchors.horizontalCenter: parent.horizontalCenter
text:"Override existing levelData"
onClicked:
{
var customValue = 5;
levelEditor.saveCurrentLevel({customData: { customValue: customValue}});
}
}
SimpleButton
{
anchors.left: parent.left
text:"SAVE"
onClicked:
{
levelEditor.clearAllLevels();
var levelId = "1"
var levelName ="TestLevel";
var customValue = 10;
var saveProperties = {levelMetaData:{ levelId: levelId, levelName: levelName}, customData: { customValue: customValue}};
levelEditor.createNewLevel()
levelEditor.saveCurrentLevel(saveProperties);
levelEditor.exportLevelAsFile();
}
}
SimpleButton
{
anchors.right: parent.right
text:"LOAD"
onClicked:
{
levelEditor.loadSingleLevel(levelEditor.applicationJSONLevels[0]);
console.log(
"LevelId: "+levelEditor.currentLevelData.levelMetaData.levelId+"\n"+
"LevelName: "+levelEditor.currentLevelData.levelMetaData.levelName+"\n"+
"CustomValue: "+levelEditor.currentLevelData.customData.customValue);
}
}
Text
{
id:textOfGround
anchors.centerIn: parent
text:ground
}
}
}
*First of all I export the level to a json file -> This works
*Then i copy this json file into my levels-folder and the load the level and log all the informations -> This works
Now i want to change the value of a custom value by calling:
levelEditor.saveCurrentLevel({customData: { customValue: customValue}});
…where customValue have been changed now.
My question now: How is it possible to change the customData of a .json Level at runtime ?
Greets,
Thomas