andreas_d Posted August 13, 2015 Share Posted August 13, 2015 Hi guys In the following code, I can see that the on each load the TextureCache is being populated with a texture. Where in the loaders processes can I access the Texture for the first time? The creation of the Texture happens after the 'onload' event (you don't have access to it in but has been executed by the time the next resource is loaded.PIXI.loader.add( AssetListA).add( AssetListB).on('load', function(e){ console.log(e); console.log(PIXI.utils.TextureCache);}).on('progress', function(loader, resource){})// .after(function(resource, next){ console.log(resource); next(); }).on('complete', function(e){init(e.resources);}).load()Thanks for the help Quote Link to comment Share on other sites More sharing options...
xerver Posted August 13, 2015 Share Posted August 13, 2015 The 'load' and 'progress' events happen before middleware parsers run (which is what creates a texture in pixi). There is an 'afterMiddleware' event that emits after a resource has been loaded and middleware has run. That event is the first event that tells you when a resource is completely ready for use. Quote Link to comment Share on other sites More sharing options...
andreas_d Posted August 13, 2015 Author Share Posted August 13, 2015 got it thanks again for all the help! For anyone who may need this, this is how I targeted the 'afterMiddleware' event. Although in retrospect you can do this using .after() as well ... PIXI.loader .add( AssetListA ) .add( AssetListB ) .on('load', function(loader, resource){}) .on('progress', function(loader, resource){ resource.once('afterMiddleware', function(resource){ console.log(resource.texture.baseTexture) }) }) // .after(function(resource, next){ console.log(resource.texture.baseTexture); next(); }) .on('complete', function(e){ init(e.resources); }) .load() ;Thanks again xerver 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.