/* * GDevelop JS Platform * Copyright 2013-2016 Florian Rival (Florian.Rival@gmail.com). All rights reserved. * This project is released under the MIT License. */ /** * PixiImageManager loads and stores textures that can be used by the Pixi.js renderers. * * @class PixiImageManager * @memberof gdjs * @param {Object} resources The resources data of the game. */ gdjs.PixiImageManager = function(resources) { this._resources = resources; // The invalid texture is a 8x8 PNG file filled with magenta (#ff00ff), to be // easily spotted if rendered on screen. this._invalidTexture = PIXI.Texture.from("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAFElEQVQoU2P8z/D/PwMewDgyFAAApMMX8Zi0uXAAAAAASUVORK5CYIIA"); this._loadedTextures = new Hashtable(); }; gdjs.ImageManager = gdjs.PixiImageManager; //Register the class to let the engine use it. /** * Return the PIXI texture associated to the specified resource name. * Returns a placeholder texture if not found. * @param {string} resourceName The name of the resource * @returns {PIXI.Texture} The requested texture, or a placeholder if not found. */ gdjs.PixiImageManager.prototype.getPIXITexture = function(resourceName) { if ( this._loadedTextures.containsKey(resourceName) ) { return this._loadedTextures.get(resourceName); } if ( resourceName === "" ) { return this._invalidTexture; } //Texture is not loaded, load it now from the resources list. if ( this._resources ) { var texture = null; for(var i = 0, len = this._resources.length;i