Hello,
I want to add two Prefabs to the scene, so here is the code:
var i = 0;
function newTile(parent, position, obj) {
var tile = cc.instantiate(obj);
tile.position = position;
tile.name = "tile"+i;
tile.parent = parent;
var image = cc.url.raw("resources/Sprites/Map/Ground/base.png");
tile.getComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(image);
i = i + 1;
}
newTile(this.node, new cc.Vec2(128,0), this.groundPrefab);
newTile(this.node, new cc.Vec2(0,0), this.groundPrefab);
However there is only the first which is display on the screen, why ?