Forums

OverviewV-Play 1 SupportChange CustomData of JSON Level › Reply To: Change CustomData of JSON Level

OverviewV-Play 1 SupportChange CustomData of JSON Level › Reply To: Change CustomData of JSON Level
#6926

wimmer92
import VPlay 1.0
import QtQuick 1.1

GameWindow {
    activeScene: scene
    
    Scene {
        id: scene

        property variant customData;

        EntityManager
        {
            id:entityManager
        }

        LevelEditor
        {
            id:levelEditor
            applicationJSONLevelsDirectory: "levels/"
            entityManagerItem: entityManager
        }

        SimpleButton
        {
            anchors.centerIn: parent
            text:"DO IT"
            onClicked:
            {
                //Load the json level from the levels folder
                levelEditor.loadSingleLevel(levelEditor.applicationJSONLevels[0]);

                //Save the customData in the property
                scene.customData = levelEditor.currentLevelData.customData;

                //Print actual value of customData
                console.log(scene.customData.customValue)

                //Modify customData
                var newValue = 1234567890;
                scene.customData = {"customValue":newValue};

                //Print actual value of customData
                console.log(scene.customData.customValue)

                var saveProperties = { levelMetaData: levelEditor.currentLevelData.levelMetaData, customData: scene.customData };
                levelEditor.saveCurrentLevel(saveProperties);

                //The json file haven't changed now !
            }
        }
    }
}

My .json File:

{“levelMetaData”:{“levelId”:”1″,”levelName”:”TestLevel”,”storageLocation”:”applicationJSON”},”customData”:{“customValue”:10}}

 

The value called “customValue” does not change in the file, but in the authorgenerated level it does.

 

What I’m doing wrong ?

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support