小编Fer*_*177的帖子

haxe将新关键字添加到具有变量的对象

我定义了一个对象数据,用于存储代码中使用的各种数据。我想在运行时插入一个新房间。例如,来自变量的新键“ 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

2
推荐指数
1
解决办法
391
查看次数

标签 统计

haxe ×1