BasomtiKombucha

Members
  • Content Count

    17
  • Joined

  • Last visited

  1. Hi,let's say I'm crating an interactive button. That means I need to listen to MouseEvents, or some kind of its equivalent that pixi has (I'm not sure how this works).The button exists for a while, and once I don't need it anymore, I remove it. My question is: do I need to remove the event listener/cancel subscription/whatever as well? Take a look at this code: var button = new PIXI.Sprite(texture);button.buttonMode = true;button.interactive = true;stage.addChild(button);button.click = function(data) { console.log("CLICK!");}stage.removeChild(button);button = null;Is it ok, or will it memory leak?
  2. Well, pixi is a rendering engine optimized from drawing large amounts of bitmap sprites. Sure it can draw primitives, but as you've pointed out, they're not really that fast. I would suggest finding a different framework for project that relies heavily on them. If you need both the bitmap sprites and the primitives then indeed, you're in a difficult position Unfortunately, I'm not experienced enough to help you with it. But finding a way to draw WebGL primitives over it sounds like a good idea to me. After all, pixi is open source, you might find a way to re-write it somehow. Hopefully someone else will be of more help than I was Good luck.
  3. Is there any chance you accidentally ask for scale.x instead of width? Could we see your code?
  4. Also try to console.log.(self.display1.hitArea) and see if it outputs something unexpected.
  5. Nevermind, I think I've figured what's up with the first one. The Graphics class has a 'padding' property that changes its bounds for some reason. Once it's set to zero, it works normally. Still unsure why it's there tho.
  6. Hi! I've noticed some really strange behavior when rendering WebGL primitives with pixi. Is this an issue, or should it behave like this? First, when asking for the primitives dimensions, they are always increased by 20: var graphics = new PIXI.Graphics();graphics.lineStyle(1, 0xffd900, 1);graphics.drawRect(0, 0, 1, 100);stage.addChild(graphics);console.log(graphics.width);console.log(graphics.height);output: 22121Second, when asked for its dimensions before there are any, the dimensions in the whole object break and there does not seem to be a way to get them once they really are in there: var graphics = new PIXI.Graphics();graphics.lineStyle(1, 0xffd900, 1);console.log(graphics.width);graphics.drawRect(0, 0, 1, 100);stage.addChild(graphics);console.log(graphics.width);output: NaNNaN
  7. Yep, the error still lingers. Texture.removeTextureFromCache('textureId').destroy(true);Would be an ideal solution, but I can't make it work. To make sure I didn't screw anything (or as little as possible) by my coding, I used the example_1_basics you included in the GitHub source (https://github.com/FedeOmoto/pixi_examples/tree/master/web/1_basics) and basically just changed the _animate method like this: int temp = 0;void animate(num value) { window.animationFrame.then(animate); // Just for fun, let's rotate mr rabbit a little. bunny.rotation += 0.1; //THIS IS WHAT I ADDED if (temp == 180) { Texture.removeTextureFromCache('bunny.png').destroy(true); } temp++; //-------------------- // Render the stage. renderer.render(stage); }This should remove the texture after about 3 seconds of runtime. But instead, after those 3 seconds, I get an error: Tho it works if I try doing it in JavaScript via the: PIXI.TextureCache['bunny.png'].destroy(true);Instead of the error, the spinning bunny changes into a black rectangle, which is what I would expect it to do.
  8. Sebastian: You are right! I didn't realize this. Nevertheless, I still think that a static getter would be more practical, but it's good to know that there's no need to change the source. Funny that the BaseTexture.destroy() method behaves differently in Dart VM that it does in JavaScript. Calling it throws an error regarding the _source.src. It seems to work ok when compiled into JavaScript tho. Of course, the problem partly lingers because of this - it's hard to debug and application if it exits every time you change a level and compiling it into JavaScript after every change is too slow. Still, I guess there's not much we can do about it since I believe it to be an issue with the port itself. But I have faith that Fede will look into it soon edit: w8 a sec Fede has responded while I was writting this post, give me a sec to read it and I'll get back
  9. Hubert: It's not that simple with the Texture._cache[frameId]; _ underscore works somehow like a 'private' keyword in dart and there is no getter for the "_cache" Still, you probably had to dig in the Dart Pixi source to get that piece of code for me and I appreciate that! It seems that the problem is unsolvable without modifying the library source. I'll write to its author and see what he thinks about it Sebastian: That was well explained! I understand it completely now, thanks!
  10. Thanks! Yep, I guess it'll to do so I'll mark it as 'the answer' very soon But before that, if I may ask just one more thing: what is the difference between: PIXI.TextureCache['image.png'].destroy(true);and PIXI.Texture.removeTextureFromCache('image.png');? My problem is that instead of using the standard pixi.js, I'm using its Dart port (https://github.com/FedeOmoto/pixi) and the port does not seem to have the TextureCache class anywhere I can get (actually, I can't even find it in the official pixi.js documentation (http://www.goodboydigital.com/pixijs/docs/) perhaps it's out of date?) Also the difference between Texture and BaseTexture is mystery to me, why do we need them both?
  11. Thanks for the reply! You're probably pushing me on the right track, but I still don't fully understand Could you be more specific? AssetLoader.load() returns void, not an instance of a Texture element - so I can't just var myTexture = loader.load();But I need to call the Texture.destroy() on something - probably some instance of the 'Texture' object, right? So how do I store an asset I loaded through loader into a 'Texture' variable? TLDR; my problem is that I don't know what should I call the "texture.destroy(true)" on :/
  12. Hi! So here's something that has been bothering me for a while... Can we somehow "unload" textures/texture atlases/assets? I'm working on a game that has multiple levels. At the start of each level, I preload all of the assets the level requires using the AssetLoader. So at the start of the first level I have something like: loader = new PIXI.AssetLoader(["level1_assets.json"]);loader.onComplete = startLevelloader.load();While at the start of the second level I have something like: loader = new PIXI.AssetLoader(["level2_assets.json"]);loader.onComplete = startLevelloader.load();The point is, once the first level is over, I will never again need the texture atlas used to store its assets (resp. "level1_assets.json"). So there's no need for it to linger in my precious GPU memory anymore! Can I somehow dispose of it?
  13. Great job! I'm certain many people will find this useful - I sure will!