galapagosit’s blog

本家 > http://galapagosit.com/

Cocos2d-JSでunderscore.jsを使う

http://underscorejs.org/# からunderscore-min.jsをダウンロードし、src配下に設置。

jsListに設置したファイルパスを追加するだけ

おまけ

_.eachを使った例

指定したノードの子要素全て、透過度を一括で変更

    fade_to_children:function (node, duration, opacity) {
        cc.log(node.getName() + " >>> fade_to_children");
        var fade_action = cc.fadeTo(duration, opacity);
        node.runAction(fade_action);
        _.each(node.getChildren(), function(element, index, array) {
              this.fade_to_children(element, duration, opacity);
        }, this);
    }