Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Properties in levels

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #6102

    Christian
    Felgo Team

    Hi, I’m having some trouble using the LevelEditor components at the moment.

    Is it possible to save additional properties of a level when saving via levelEditor.saveCurrentLevel()?

    For example, the levels in our game have varying width, height, they have a static Player entity whose x and y values are different in each level, and so on.

    When I save (export) the level, a JSON file gets generated in my documents folder, but it appears only the entities that were stated in “toStoreEntityTypes” are saved, but no properties of the level itself?

     

    Furthermore, i kind of don’t get how to save a level to authorGeneratedLevels?

    After calling saveCurrentLevel() they don’t appear in the LevelSelectionList even after calling

    levelEditor.loadAllLevelsFromStorageLocation(levelEditor.authorGeneratedLevelsLocation)

    and then in LevelEditor:

    onLoadAllLevelsFromStorageLocationFinished: {
                console.log("load finished, levels: " + JSON.stringify(allLevelsData))
                worldScene.levelSelector.levelMetaDataArray = allLevelsData
            }
    

    Did I miss something?

     

    Cheers, Chrisu

     

    #6104

    David

    Hi Chrisu,

    Yes, indeed! It is possible to store additional data! There are 2 ways to achieve it, which you can find in the Squaby Demo in the latest Daily Build:

     

    1. You are using EditableComponents to define the data and use an ItemEditor to store the values which get automatically included in your level file (s. Squaby: LevelEmpty.qml).
    2. You use levelData.customData to store your level data manually (s. Squaby: SquabyLevelBase.qml).

     

    property alias pathEntity: pathEntity
    property alias waypoints: pathEntity.waypoints
    
    onLevelAboutToBeSaved: {
      // modify customData property so it gets stored with the level
      levelData.customData = { waypoints: squabyLevelBase.waypoints }
    }
    
    onLevelLoaded: {
      // no waypoints might have been stored
      if(levelData.customData && levelData.customData["waypoints"]) {
        pathEntity.initializeFromWaypoints(levelData.customData.waypoints)
      }
    }

     

    Basically when calling saveCurrentLevel() the level always gets saved also to the authorGeneratedLevelsLocation. Your code posted should work as expected. Are there any error or warning log messages? You can check the sql DB after saving the level if the level data is stored correctly. You can use SQLite Database Browser for this task on your Deskop workstation (http://sourceforge.net/projects/sqlitebrowser/).

     

    Cheers,

    David

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded