我有
var world = 'here are positions of the blocks and character Mario';
我希望将“Mario”改为另一个角色(例如,“Luigi”)。
var res = world.replace("Mario", "Luigi");
现在我需要将带有world和更改字符的代码(res)写入此文件以供引擎加载。
window._world = {
id: 3,
tiles: [],
x: 0,
y: 0,
tileWidth: 32,
tileHeight: 32,
width: 212,
height: 17,
backgroundColor: "rgba(66, 66, 255, 1)",
name: "level_1-1",
sprites: [
**Here I need write the variable res with changed character**
],
我该怎么做?
答案 0 :(得分:0)
我以为你期待这件事:
var world = 'here are positions of the blocks and character mario';
var res = world.replace("mario", "luigi");
window._world = {
id: 3,
tiles: [],
x: 0,
y: 0,
tileWidth: 32,
tileHeight: 32,
width: 212,
height: 17,
backgroundColor: "rgba(66, 66, 255, 1)",
name: "level_1-1",
sprites: [res]
}
console.log(window._world)