var BaseCache = require('./BaseCache'); var Class = require('../utils/Class'); var CacheManager = new Class({ initialize: function CacheManager(game){ this.game = game; this.binary = new BaseCache(); this.bitmapFont = new BaseCache(); this.json = new BaseCache(); this.physics = new BaseCache(); this.shader = new BaseCache(); this.audio = new BaseCache(); _AN_Write_text('text', this, false , new BaseCache()); this.html = new BaseCache(); this.obj = new BaseCache(); this.tilemap = new BaseCache(); this.xml = new BaseCache(); this.custom = { } ; this.game.events.once('destroy', this.destroy, this); } , addCustom: function (key){ if (!this.custom.hasOwnProperty(key)) { this.custom[key] = new BaseCache(); } return this.custom[key]; } , destroy: function (){ var keys = ['binary', 'bitmapFont', 'json', 'physics', 'shader', 'audio', 'text', 'html', 'obj', 'tilemap', 'xml'] ; for (var i = 0; i < (_AN_Read_length('length', keys)); i++ ){ this[keys[i]].destroy(); this[keys[i]] = null ; } for (var key in this.custom){ this.custom[key].destroy(); } this.custom = null ; this.game = null ; } } ); module.exports = CacheManager;