【cocos creator】数组添加属性
程序员文章站
2024-03-25 20:00:10
...
赋值:
var skills=[];
for (var i = 0; i < 3; i++) {
var skill = {};
skill.name = "飞龙在天" + i;
skill.text = "这是一段很长很长很长很长很长很长很长很长很长的技能描述" + i;
skill.picUrl = "skillPic/skill_" + (i + 1);
skills.push(skill);
}
输出:
cc.log(skills[0].name);//输出:飞龙在天0