since version 1.3 we support file reading with System::readFile(). However, in most cases you can achieve a better code style by defining a base QML file (like a LevelBase.qml) and then create multiple instances of it by subclassing this QML file.
If you just read levels, it is easier to define the levels in QML file and you do not need the loading from a file.
Have a look at the demo games like Squaby, where this concept is shown in detail.
Consider the following code:
// the blocks variant could be any array or a map you define in the levels
property variant blocks
// enter any level data here you need for your game
blocks: [[10, 30, 50], [5, 10, 5]]
then, for loading the level:
source: "Level01.qml" // select any level here, possibly from a level selection scene
This is the suggested workflow with QML. File reading is only necessary if you also want to save some files, which is not the case I guess.
Want to find out if Felgo is a good fit for your company?
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: