sussyboi Posted January 11, 2021 Share Posted January 11, 2021 I am currently trying to implement a system where placeholder images can be displayed while the actual images are being loaded. I would like to ask for some examples that have already done this using PIXIjs. Structure I came up with: export class ImageDefinition { placeholder: PIXI.Texture resource: PIXI.LoaderResource callbacks: ((texture: PIXI.Texture) => void)[] = [] loaded: boolean = false GetTexture(callback: (texture: PIXI.Texture) => void): void { if(!this.resource.isComplete) { callback(this.placeholder) return } this.callbacks.push(callback) } // This function is called by the asset loader LoadCompleted() { // Run all callbacks here } } How this would be used: probabilityTexture.GetTexture((texture) => { // this code will be run twice, for placeholder and later for real image }); What do you think about the system above? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 12, 2021 Share Posted January 12, 2021 @xerver probably has code like that 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.