• Content Count

  • Joined

  • Last visited

  1. Is it possible to use SpriteBatch with PIXI.Text? Or it's like using differente textures?
  2. So isn't there any reference in PIXI about the Sprite Textures that still need to be rendered?
  3. The only thing that comes into my mind is to use cacheAsBitmap = true; and then apply the opacity.
  4. I also tried to check at PIXI.Texture.frameUpdates and PIXI.texturesToUpdate, but their length is always 0 after a render loop (while the Sprite aren't updated yet).
  5. It could be connected with this PIXI code: PIXI.WebGLFastSpriteBatch.prototype.renderSprite = function(sprite){ //sprite = children[i]; if(!sprite.visible)return; // TODO trim?? if(sprite.texture.baseTexture !== this.currentBaseTexture) { this.flush(); this.currentBaseTexture = sprite.texture.baseTexture; if(!sprite.texture._uvs)return; } ......
  6. Sorry Sebastian, it was "Pseudo code". I can't paste the whole code: it's too long. However this is the "actual code" that I have now (I still have to remove the .bind()): ViewManager.prototype.animationLoop = function () { var self = this; // Own reference for inner functions var self = this; // Own reference for inner functions TWEEN.update(); // Update animations self.renderer.render(self.stage); // Render the Stage // Check if still animating or if there are updates if (self.animating || self.updatesCount !== 0) { // Continue animation loop (used with bind to have the right scope) requestAnimationFrame(self.animationLoop.bind(self)); self.flag = 0; } else if (self.updatesCount === 0) { if (self.flag < 50) { requestAnimationFrame(self.animationLoop.bind(self)); self.flag += 1; console.log(self.flag) } else { console.log("stop") } } };Pratically it runs 50 rendering loops after all updates are complete, but it still doesn't work: some sprites are updated and some sprites aren't. But it's a "rendering problem", because in the exact moment that I replay the loop, they are updated (even if they are very big textures, so it means that they were downloaded and applied, just not rendered). N.B.: the "self.flag" was just a testing variable.
  7. Thank you Alex_h! I knew how bind worked, but I really didn't think about it... it could improve the performance!
  8. Hi guys, I have the following problem: I have an app that shows 100 Sprites, but these change their texture on user interactions. The problem is that I'd like to stop the PIXI animation loop after textures are updated (to stop the app using CPU while idle), but I can't. The animation loop is simple: animationLoop = function () { var self = this; self.renderer.render(self.stage); // Render the Stage // Check if still animating if (self.animating) { // Continue animation loop (used with bind to have the right scope) requestAnimationFrame(self.animationLoop.bind(self)); }};I created some code to stop the animation after the textures are updated. Pratically, after the method "sprite.setTexture()" is invoked on every Sprite, I just call self.animating = false;So that the animation loop ends. But it doesn't work: PIXI needs a (random) number of iterations of the rendering loop to update textures! So: is there any way to know when the texture are all updated? Thanks
  9. I know that, what I'd like to know if in someway (like changing the code manually) it could be "technically" possible to use only the tinting feature, or if it renders Sprites in a way that it isn't usable at all.
  10. However I have the same problem another time, but this time would be too expensive to create an overlay transparent layer. So how could I change manually the PIXI code to let a SpriteBatch be interactive? Or, better, I need something like the HTML "map tag"...
  11. 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.WebGLFastSpriteBatch.render PIXI.SpriteBatch._renderWebGL PIXI.DisplayObjectContainer._renderWebGL PIXI.DisplayObjectContainer._renderWebGL PIXI.DisplayObjectContainer._renderWebGL PIXI.WebGLRenderer.renderDisplayObject PIXI.WebGLRenderer.render ViewManager.animationLoop
  12. 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 null Do you know what could it be?
  13. I solved using an overlay trasparent layer with buttons. It takes more time to create it, but buttons have alpha = 0, so they aren't rendered. Thank you guys for your support!
  14. the SpriteBatch as the DisplayObjectContainer. It's a subclass of DisplayObject so it should work, but it doesn't. The problem is that if you add it in another container it still doesn't work.
  15. Is it normal that Sprites inside a SpriteBatch can't be interactive? I also tried to add a SpriteBatch in a DisplayObjectContainer for interactivity, but it doesn't work. Do you have any idea?