Jump to content

Textures loading slowly when first added


henrikland
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...