Forums

OverviewV-Play 1 Support › Properties in levels

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

    Christian
    V-Play 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.

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