cocos creator创建新节点


cc.Class({
  extends: cc.Component,

  properties: {
    sprite: {
      default: null,
      type: cc.SpriteFrame,
    },
  },

  start: function (){
    var node = new cc.Node('sprite ' +this.count);
    var sp = node.addComponent(cc.Sprite);

    sp.spriteFrame = this.sprite;
    node.parent = this.node;
    node.setPosition(0,0);
  },
});

你可能感兴趣的:(js)