<commit_before>
;(function( FooFighter ){

function SpriteFactory ( gameState ) {
    this.gameState = gameState;
    this.game = gameState.game;
}

var proto = SpriteFactory.prototype;


proto.createSprite = function( sheet, frame, options ){
    var game = this.game,
        group = options.group || null,
        anchor = options.anchor || null,
        align = options.align || null,
        x = options.x,
        y = options.y,
        events = options.events || null,
        event,
        i,
        handlers,
        sprite;

    if ( align === 'center' ) {
        x = game.world.centerX;
        y = game.world.centerY;
    }

    if ( group === null ) {
        sprite = game.add.sprite(x, y, sheet, frame);
    } else {
        sprite = group.create(x, y, sheet, frame);
    }

    if ( anchor !== null ) {
        sprite.anchor = {
            x: anchor.x,
            y: anchor.y
        };
    }

    if ( events !== null ) {
        for ( event in events ) {
            handlers = events[event];
            for ( i = 0; i < handlers.length; i++ ) {
                sprite.events[event].add(handlers[i]);
            }
        }
    }

    return sprite;
};


FooFighter.SpriteFactory = SpriteFactory;
<commit_msg>add recycleSprite method to SpriteFactory<commit_after>
;(function( FooFighter ){

function SpriteFactory ( gameState ) {
    this.gameState = gameState;
    this.game = gameState.game;
}

var proto = SpriteFactory.prototype;


proto.createSprite = function( sheet, frame, options ){
    var game = this.game,
        group = options.group || null,
        anchor = options.anchor || null,
        align = options.align || null,
        x = options.x,
        y = options.y,
        events = options.events || null,
        event,
        i,
        handlers,
        sprite;

    if ( align === 'center' ) {
        x = game.world.centerX;
        y = game.world.centerY;
    }

    if ( group === null ) {
        sprite = game.add.sprite(x, y, sheet, frame);
    } else {
        sprite = group.create(x, y, sheet, frame);
    }

    if ( anchor !== null ) {
        sprite.anchor = {
            x: anchor.x,
            y: anchor.y
        };
    }

    if ( events !== null ) {
        for ( event in events ) {
            handlers = events[event];
            for ( i = 0; i < handlers.length; i++ ) {
                sprite.events[event].add(handlers[i]);
            }
        }
    }

    return sprite;
};


proto.recycleSprite = function( group, options ){
    var sprite;

    if ( typeof group === 'undefined' ) {
        throw new Error('Recycle functionality requires a group.');
    }

    sprite = group.getFirstExists(false);

    if ( !sprite ) {
        return false;
    } else {
        sprite.revive();
        sprite.reset(options.x, options.y);
    }

    return sprite;

};


FooFighter.SpriteFactory = SpriteFactory;

{'fraction_non_alphanumeric': 0.13020833333333334, 'fraction_numerical': 0.0006944444444444445, 'mean_word_length': 1.7411988582302569, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1853971', 'n_tokens_mistral': 913, 'n_tokens_neox': 886, 'n_words': 213}