Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

resource loader - earliest access to Texture


andreas_d
 Share

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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...