Jump to content

How to update texture for AnimatedSprite


Recommended Posts

I have image with 10 different animations and 10 frames by each. On stage i have for example set of 15 diffeent objects with animation.

From time to time i have to change set of animation to another.One way to do this is to delete objects and create them once more with needed sprite animation.

var moveClip1 = createClip(5);

createClip: function (symbolIndex) {
    var image = this.game.getImage('images.symbols');
    var base = new PIXI.BaseTexture(image);
    var textures = [];
    for (j = 0; j < steps; j++)
       tempTexture = new PIXI.Texture(base, {
       x: this.game.symbolHeight * j,
       y: this.game.symbolWidth * symbolIndex,
       width: this.game.symbolHeight,
      height: this.game.symbolWidth
   symbolClip= new PIXI.extras.AnimatedSprite(textures);

return (symbolClip)


Is it posible to change texture in existing object moveClip1 without recrete the object? 

Link to comment
Share on other sites

  • vesantpro changed the title to How to update texture for AnimatedSprite

Would you mind to help me? I have object  moveClip1, and i have to change sprite sheet in it without deleting this object.

Something like this:  

moveClip1= new PIXI.extras.AnimatedSprite(oldTextures);

moveClip1.textures =newTextures;

For exapmlpe in case of simple Pixi sprite we have method to update texture :

sprite1 = new PIXI.Sprite(oldTexture);
newTexture = new PIXI.Texture(baseTexture);
sprite1.texture = newTexture;


Link to comment
Share on other sites

Thank you Ivan, it realy works! I  just asign new textures aray to existing AnimatedSprite.

Also spend some problems with webGL context. After 8-10 texture changes i 'm geting  Chrome console error.

         (W10 64bit, Chome 56 64bit, Video  GeForce GTX 650 with last driver)

GL_INVALID_OPERATION : glGenSyncTokenCHROMIUM: fence sync must be flushed before generating sync token

WebGL: CONTEXT_LOST_WEBGL: loseContext: context lost

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.

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.


  • Recently Browsing   0 members

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