properties: {
	 PrefabName:cc.Prefab,
     PrefabX:0,
     PrefabY:0,
	 ...
	 }

函数

   showPrefab(PrefabName,x,y){
        var newItem = cc.instantiate(PrefabName);
        // 设置位置
        newItem.setPosition(x,y);
        // 将新增的节点添加到 Canvas 节点下面
        this.node.addChild(newItem);
        return newItem;
    },

调用

this.showPrefab(this.PrefabName,this.PrefabX,this.PrefabY);
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐