我定义了一个对象数据,用于存储代码中使用的各种数据。我想在运行时插入一个新房间。例如,来自变量的新键“ R200”,但到目前为止尚未成功。
static public var data =
{
room: {
"R100": {monstersLeft: 2 }
}
}
// need to add the the object data :
// would like to reference is like:
var newRoom = "R200";
???? data[newRoom ].monstersLeft = 5;
trace(data.R200.monstersLeft)
Run Code Online (Sandbox Code Playgroud) haxe ×1