The level data is loaded in GameLayer
.
Inside the
GameLayer
constructor, we load the data like this:_levels = FileUtils::getInstance()- >getValueVectorFromFile("levels.plist");
Cocos2d-x will take care of mapping
FileUtils
to the correct target. There isFileUtils
for each platform that is supported by the framework and they all can be made to work with the.plist
format. Sweet! If the data in the.plist
file is an Array, you must convert it toValueVector
; if it's Dictionary, you must convert it to aValueMap
. We'll do that next when we load the data for a specific level.Inside the
loadLevel
method, we load the data for the level like this:ValueMap levelData = _levels.at(_currentLevel).asValueMap();
Here, the data in the
.plist
file is Dictionary, so we must convert the data into aValueMap...