如何動態加入腳本

小的新手不太懂
請各位大大教教小的如何動態加入腳本

game.js


onLoad: function () {
        for(var i = 0; i < this.monsterAmount; i++)
        {
            var node = new cc.Node("Monster" + i);
            //node.addComponent("enemy");  //不知是不是這樣載入腳本

            var sp = node.addComponent(cc.Sprite);            
            var texture = cc.textureCache.addImage(cc.url.raw("resources/PurpleMonster.png"));
            sp.spriteFrame = new cc.SpriteFrame(texture);
    
            node.parent = this.node;
            node.setPosition((cc.randomMinus1To1() * this.node.width/2), (cc.randomMinus1To1() * this.node.height/2));
        }
},

enemy.js


onLoad: function () {
    this.restAction = this.setRestAction();
    this.node.runAction(this.restAction);
},
    
setRestAction: function() {
    var squash = cc.scaleTo(this.squashDuration, 1, 0.9);
    var stretch = cc.scaleTo(this.squashDuration, 1, 1.1);
    var scaleBack = cc.scaleTo(this.squashDuration, 1, 1);
        
    return cc.repeatForever(cc.sequence(squash, stretch, scaleBack));
},