notalentgeek Posted January 8, 2020 Share Posted January 8, 2020 These codes below: const bunnyTexture = new Texture.from('bunny.png'); const bunnySprite = new Sprite(bunnyTexture); And these codes below: const bunnySprite = Sprite.from('bunny.png'); Both codes seem do the same thing.... What are the differences? What is the best practice? Are the one is better than the other one on certain cases, etc.. Quote Link to comment Share on other sites More sharing options...
themoonrat Posted January 8, 2020 Share Posted January 8, 2020 You'll get the same result in doing both. If you were gonna reuse that texture in other Sprites later on, it might be handy to have a reference to it? Otherwise I'd use the 2nd because it's quicker to type Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 8, 2020 Share Posted January 8, 2020 PixiJS is not a black box. https://github.com/pixijs/pixi.js/blob/dev/packages/sprite/src/Sprite.js#L514 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.