henrikland Posted June 8, 2016 Share Posted June 8, 2016 Hello! I have an object ("subclass" of PIXI.Sprite) whose texture I want to change at every frame, to create an animation. To do this, I use PIXI.loader.add and set up the object with a reference to the list of textures that it will use, and then change the texture property in the update loop: function Effect(textureUrls) { this.urls = textureUrls; PIXI.Sprite.call(this, PIXI.loader.resources[this.urls[0]].texture); // ... } Effect.prototype.update = function(delta) { // ... var url = this.urls[this.frameIndex]; this.texture = PIXI.loader.resources[url].texture; } My problem is that the framerate drops drastically during the first run through the animation, and on subsequent runs it goes smoothly. Any ideas on how to fix this? Is there a more efficient way of changing the texture than just setting the texture property? Due to other constraints in the project using a Texture Atlas is sadly not an option. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 8, 2016 Share Posted June 8, 2016 That's WebGL issue. Upload textures to GPU before you start the game //pixiv3 renderer.updateTexture(tex); //pixiv4 renderer.textureManager.updateTexture(tex); Quote Link to comment Share on other sites More sharing options...
henrikland Posted June 8, 2016 Author Share Posted June 8, 2016 Thank you very much! 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.