initJson(){
assetManager.loadRemote('https://xxxx.com/my.json', JsonAsset,(err, jsonData) => {
let data = jsonData.json
console.log(data)
//将图片的坐标转换到NODE的坐标
data.forEach((element, index) => {
this.config[index] = element
this.config[index].y = element.y * 420 / 500
this.config[index].x = element.x * 720 / 800
this.config[index].width = element.width * 720 / 800
this.config[index].height = element.height * 420 / 500
this.config[index].icon = '0'
});
console.log(this.config)
})
}
stargame(){
this.config = []
this.initJson()
}
每执行一次 startgame(), 打印出的data数据都不一样,一次比一次小,比如第一次打印出的data[0].y就是远程JSON数据中的data[0].y,而第二次打印出来的
data[0].y=data[0].y* 420 / 500 的值,这怎么还改变了加载远程数据JSON数据的值 ,远程的json数据格式为:
[
{
“x”: 284.5,
“y”: 303.5,
“width”: 182.5,
“height”: 156.5,
},
{
"x": 12,
"y": 319,
"width": 181,
"height": 171
}]