zarstar Posted September 11, 2014 Share Posted September 11, 2014 Hi guys,I have a very particoular problem with PIXI. Pratically I have a component that loads images and apply it in an async way when they are loaded:sprite.loader = new PIXI.ImageLoader(url);sprite.loader.onLoaded = function () { var texture; // Texture to apply // Check if a crop was passed if (typeof crop !== 'undefined') { // Create a new Texture by cropping the loaded Texture texture = new PIXI.Texture(PIXI.TextureCache[url], crop); } else { texture = PIXI.TextureCache[url]; } // Apply the Texture to the Sprite self.applyTexture(sprite, texture, size, zoom); // Invoke the callback if specified if (typeof callback === 'function') { callback(sprite); }};Now I have another component that sets the Sprite in a relative SpriteBatch, based on its BaseTexture: // Get the ID of the Texture textureId = sprite.texture.baseTexture.imageUrl; // Get the SpriteBatch relative to the Texture spriteBatch = self.SpriteBatches[sprite.texture.baseTexture.imageUrl]; // Check if there exist a SpriteBatch for the Texture, otherwise create it. // (to improve performance a SpriteBatch should have only Sprites with the same BaseTexture) if (typeof spriteBatch === 'undefined') { spriteBatch = new PIXI.SpriteBatch(); // Create the SpriteBatch container self.SpriteBatches[sprite.texture.baseTexture.imageUrl] = spriteBatch; // Store it self.container.addChild(spriteBatch); // Add it to the main Container in the Stage } // Get the Sprite parent (current container) parent = sprite.parent; // Add the Sprite in the SpriteBatch spriteBatch.addChild(sprite);}Now it seems to work, but when it loads a new Texture for the sprites (the first code I wrote), it gives the error:Uncaught TypeError: Cannot read property 'x0' of nullpixi.dev.js:8200 Do you know what could it be? Quote Link to comment Share on other sites More sharing options...
zarstar Posted September 11, 2014 Author Share Posted September 11, 2014 This is the way I am applying texture:self.applyTexture = function (sprite, texture, size, zoom) { // Set Texture to Sprite sprite.setTexture(texture); // Update Sprite size this.updateSpriteSize(sprite, zoom); };And this is the call stack:PIXI.WebGLFastSpriteBatch.renderSprite pixi.dev.js:8200PIXI.WebGLFastSpriteBatch.render pixi.dev.js:8135PIXI.SpriteBatch._renderWebGL pixi.dev.js:2243PIXI.DisplayObjectContainer._renderWebGL pixi.dev.js:1678PIXI.DisplayObjectContainer._renderWebGL pixi.dev.js:1678PIXI.DisplayObjectContainer._renderWebGL pixi.dev.js:1678PIXI.WebGLRenderer.renderDisplayObject pixi.dev.js:6680PIXI.WebGLRenderer.render pixi.dev.js:6610ViewManager.animationLoop Quote Link to comment Share on other sites More sharing options...
xerver Posted September 12, 2014 Share Posted September 12, 2014 Sounds related to the retina display changes that were made recently. I would mention this issue here: https://github.com/GoodBoyDigital/pixi.js/issues/621 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.