Jump to content

Brain Fart, Multiple frames from the same Image


rolyataylor2
 Share

Recommended Posts

Ok so like 12 koopas on screen each is the same image but a different frame.

 

I do 

koopa001.texture = new PIXI.Texture.fromImage('koopa.png');koopa001.texture.setFrame(new PIXI.Rectangle(0,0,32,32));

then i do

koopa002.texture = new PIXI.Texture.fromImage('koopa.png');koopa002.texture.setFrame(new PIXI.Rectangle(32,0,32,32));

the problem is that koopa001.texture === koopa002.texture and when i set koopa002.texture's frame it changes koopa001.texture's frame

 

I need 2 seperate textures from the same image.....

Link to comment
Share on other sites

Correct, because they are cached. You are looking to reuse the same base texture, with different frames. You are looking for this:

koopa001.texture = new PIXI.Texture(PIXI.BaseTexture.fromImage('koopa.png'));
Note that the .fromImage methods are not constructors, so you do not use the "new" keyword with them.
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...