powerfear Posted May 30, 2013 Share Posted May 30, 2013 Hello, I've been using pixi.js recently and I noticed that you can set a frame basically a subregion of a texture but that is done on the texture itself wich is a bit strange in my opinion. Wouldn't it be better to be able to set the frame on the sprite rather then on the texture? That way example if you have many sprite with a walking animation, you can use the same single texture for all the sprite and simply individually change their frame, so they are able to display a different state of the animation while using the same texture. Most framework I used did it that way but maybe I didn't look at the source properly and we can already do that? If not I think it would be a great thing to change. Quote Link to comment Share on other sites More sharing options...
Ezelia Posted May 31, 2013 Share Posted May 31, 2013 Agree with you, I noticed that too but thought I was just missing something Quote Link to comment Share on other sites More sharing options...
Mat Groves Posted May 31, 2013 Share Posted May 31, 2013 Hi guys! I see where you are coming from. When I first built pixi that was exactly how it worked. In the end I decided to go down the current path as it offers a little more flexibility. This method allows you to store frames and textures together and allows for a simple unified way (setTexture) of modifying a sprites texture regardless of if it is a frame change or a texture change. In pixi terms a "Texture" consists of a frame and a baseTexture. A texture object has a pretty tiny memory footprint its the baseTexture where the actual image is stored. The idea is that for each walking frame you create a a texture with the correct frame and baseTexture. Then each frame you swap textures (These textures could also be shared amongst many entities) Heres an example of how to create textures with various frames: http://renaun.com/blog/2013/03/using-illustrator-from-the-adobe-creative-cloud-and-pixi-js-to-create-an-8-way-character-animation/ That said there are plenty of ways to skin a cat! The method you are suggesting would work too. You can create a texture for each sprite and change the frame each time if you prefer. On the surface this may look like you would be creating lots of duplicated images but under the hood they all would share the same baseTexture. Hope that clears things up a bit orpgol 1 Quote Link to comment Share on other sites More sharing options...
Ezelia Posted May 31, 2013 Share Posted May 31, 2013 absolutely, makes sense for me now 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.