<commit_before>var Cocos2dJsHelper = cc.Class.extend({
    // collision types
    COLLISION_SUCCESS: 10000,

    // events
    EVENT_DIE: 'EVENT_DIE',
    EVENT_PASS_LEVEL: 'EVENT_PASS_LEVEL',
    EVENT_PLAY: 'play',
    EVENT_GAME_OVER: 'game_over',
    EVENT_WIN_SCORE: 'win_score',

    // obstacle types

    // direction
    DIRECTION_LEFT: 'left',
    DIRECTION_RIGHT: 'right',

    // config
    CONFIG_PATH: 'config.json',
    CONFIG_DEBUG: 'debug',
    CONFIG_MAX_CHAPTER: 'max_chapter',
    CONFIG_MAX_LEVEL: 'max_level',
    CONFIG_BEST_SCORE: 'best_score',
    configDefaults: {
        best_score : {
            invalid: null,
            default: 0
        }
    },

    // constants
    SCENE_DURATION: 1,
    MAX_LEVEL_COUNT: 10000,

    // variables
    center: null,
    space: null, // Chipmunk space object
    score: 0,
    currentChapter: -1,
    currentLevel: -1,

    init: function () {
        var size = cc.winSize;
        this.center = cc.p(size.width * 0.5, size.height * 0.5);
        this.currentChapter = this.configMaxChapter();
        this.currentLevel = this.configMaxLevel();

        _.forEach(this.configDefaults, function (v, k) {
            var cv = this.config(k);
            if (cv === v.invalid) {
                this.config(k, v.default);
            }
        }.bind(this));
    },
    label: function (text, size) {
        return new cc.LabelTTF(text, 'Arial', size || 40);
    },
    animate: function (prefix, count, interval, revert) {
        var frames = [],
            i = 0,
            frame = null;
        if (revert) {
            for(i = count; i >= 1; i--) {
                frame = cc.spriteFrameCache.getSpriteFrame(prefix + i + '.png');
                frames.push(frame);
            }
        } else {
            for(i = 1; i <= count; i++) {
                frame = cc.spriteFrameCache.getSpriteFrame(prefix + i + '.png');
                frames.push(frame);
            }
        }
        var ani = new cc.Animation(frames, interval);
        return cc.animate(ani);
    },
    addDebugNode: function () {
        this._debugNode = new cc.PhysicsDebugNode(this.space);
        this._debugNode.visible = this.config(this.CONFIG_DEBUG);
        this.addChild(this._debugNode, 9999);
    },
    logColors: function (colors) {
        var result = [];
        _.forEach(colors, function (v, k) {
            result.push(cc.colorToHex(v));
        });
        cc.log(result);

        return result;
    },
    cpVerts: function (verts) {
        var result = [];<commit_msg>Fixed the bug of function "addDebugNode".<commit_after>var Cocos2dJsHelper = cc.Class.extend({
    // collision types
    COLLISION_SUCCESS: 10000,

    // events
    EVENT_DIE: 'EVENT_DIE',
    EVENT_PASS_LEVEL: 'EVENT_PASS_LEVEL',
    EVENT_PLAY: 'play',
    EVENT_GAME_OVER: 'game_over',
    EVENT_WIN_SCORE: 'win_score',

    // obstacle types

    // direction
    DIRECTION_LEFT: 'left',
    DIRECTION_RIGHT: 'right',

    // config
    CONFIG_PATH: 'config.json',
    CONFIG_DEBUG: 'debug',
    CONFIG_MAX_CHAPTER: 'max_chapter',
    CONFIG_MAX_LEVEL: 'max_level',
    CONFIG_BEST_SCORE: 'best_score',
    configDefaults: {
        best_score : {
            invalid: null,
            default: 0
        }
    },

    // constants
    SCENE_DURATION: 1,
    MAX_LEVEL_COUNT: 10000,

    // variables
    center: null,
    space: null, // Chipmunk space object
    score: 0,
    currentChapter: -1,
    currentLevel: -1,

    init: function () {
        var size = cc.winSize;
        this.center = cc.p(size.width * 0.5, size.height * 0.5);
        this.currentChapter = this.configMaxChapter();
        this.currentLevel = this.configMaxLevel();

        _.forEach(this.configDefaults, function (v, k) {
            var cv = this.config(k);
            if (cv === v.invalid) {
                this.config(k, v.default);
            }
        }.bind(this));
    },
    label: function (text, size) {
        return new cc.LabelTTF(text, 'Arial', size || 40);
    },
    animate: function (prefix, count, interval, revert) {
        var frames = [],
            i = 0,
            frame = null;
        if (revert) {
            for(i = count; i >= 1; i--) {
                frame = cc.spriteFrameCache.getSpriteFrame(prefix + i + '.png');
                frames.push(frame);
            }
        } else {
            for(i = 1; i <= count; i++) {
                frame = cc.spriteFrameCache.getSpriteFrame(prefix + i + '.png');
                frames.push(frame);
            }
        }
        var ani = new cc.Animation(frames, interval);
        return cc.animate(ani);
    },
    addDebugNode: function (parentNode) {
        parentNode._debugNode = new cc.PhysicsDebugNode(this.space);
        parentNode._debugNode.visible = this.config(this.CONFIG_DEBUG);
        parentNode.addChild(parentNode._debugNode, 9999);
    },
    logColors: function (colors) {
        var result = [];
        _.forEach(colors, function (v, k) {
            result.push(cc.colorToHex(v));
        });
        cc.log(result);

        return result;
    },
    cpVerts: function (verts) {
        var result = [];
{'fraction_non_alphanumeric': 0.13135428793170353, 'fraction_numerical': 0.011253395421032208, 'mean_word_length': 1.8976953344575604, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2916735', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1594, 'n_words': 340}