我有这个代码:
const settings = {
notes: [new musicnote(480,400,"wav/1.wav","cyan",true)],
emiters: [new emiter(300,240), new emiter(340,240)]
}
var notes = [];
var emiters = [];
var LoadLevel = function (level) {
if(settings[level] !== undefined){
currentLevel = level;
notes = settings[level].notes;
emiters = settings[level].emiters;
}
}
当我emiters
在游戏中更改数组(删除或添加一些)时,它对settings.emiter
数组的作用相同。所以我的问题是 - 如何在settings
对象中传递一个新数组而不是对数组的引用?