代码如下:
resources.load(“config/GameSetting”, JsonAsset, (err, jsonAsset) => {
if (err) {
console.log(err);
} else {
let jsonObject = jsonAsset.json;
this.TouchSpeedX = jsonObject.TouchSpeedX;
this.TouchSpeedY = jsonObject.TouchSpeedY;
}
});
json内容如下:
{
“TouchSpeedX”: 0,
“TouchSpeedY”: 0
}
其中jsonObject.TouchSpeedX和jsonObject.TouchSpeedY报错。