computern Posted February 16, 2018 Share Posted February 16, 2018 Hi, I am currently having an issue where changing the frame of a texture for one sprite is updating the frame of the texture on all my sprites. I want each sprite to use the same texture but be able to display a different frame of it. (Please note I am using Pixi.js 4.5.1 as it doesnt break my game) my code: let outlineskin = resources["Resources/mask.png"].texture; outlineskin.frame = new PIXI.Rectangle(20*number,0,20,40); this.outline.texture = outlineskin; but by changing the frame of mask.png it updates every sprite that has the texture mask.png to that frame. I need to be able to constantly change the frame as the sprite moves. I presume there is a better way to code this, any help would be much appreciated ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 17, 2018 Share Posted February 17, 2018 That question was asked too many times. you need a copy of the texture. Basically, texture is the baseTexture+frame. let newTexture = new PIXI.Texture(oldTexture.baseTexture, oldTexture.frame); just pass new frame there, or change it later. computern 1 Quote Link to comment Share on other sites More sharing options...
computern Posted February 17, 2018 Author Share Posted February 17, 2018 Works great. Thanks a lot dude 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.