New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssetLoader call onComplete only once #28
Comments
Thanks for the heads up! Seems to be the same issue as this: #13 |
Chrome 25 and Firefox 19 , it might be 'hasLoaded' problem : but it should be probably : if(!texture.baseTexture.hasLoaded) Im not sure , just hinting |
I agree, will take a poke around later today. Annoyingly I cant seem to recreate the issue on my current setup, would you mind testing the fix for me once its complete? |
Now Im 99% sure that this is an issue because this code works fine : if (PIXI.Texture.fromImage("asset/shadow.png").baseTexture.hasLoaded) { Ok , I'll download latest when You fix it and give You feedback ! |
yeah , but it must work anyway, cache or download :) |
Quick test :) If you swap these two lines around in the PIXI.Texture.fromImage function: image.src = imageUrl;
baseTexture = new PIXI.BaseTexture(image); like this:
does that fix the issue? |
baseTexture = new PIXI.BaseTexture(image);
image.src = imageUrl; and, PIXI.BaseTexture = function(a) {
this.height = this.width = 0;
if (this.source instanceof Image)
if (this.source.width) //"complete" property is buggy its always "true" I think it is ok. |
Nope , but I was right about "hasLoaded" param . Please look at code : Texture object dont have property "hasLoaded" so (!texture.hasLoaded) will be always true and it try load and never end , but it should skip it . There must be : and at end of function : This solved problem . |
Oh yes! you are absolutely correct 👍 Great catch! |
Thats a pain of js . Im moving from as3 to js and no strong type can cause big headaches :) btw any plans of adding solid color graphic rects ? |
I hear that! I come from as3 land too :) |
yeah , thats very usefull , just like starilng quads . I'll try also implement this in Your lib : http://turbosqel.pl/relativestarling/ |
nice one 👍 |
Hello! @turbosqel 's answer worked for me, just note that the code should be: if(!texture.baseTexture.hasLoaded) Copy and paste on the other code will give you an error. ;) Please, let me know when this fix is added to the repo, so I can go back to work with the most recent version. By the way, awesome library! Thanks a lot! |
Dont forget to add : on botton of "load()" function , because loader wont call onComplete without it |
One more thing, the function PIXI.AssetLoader.prototype.onAssetLoaded Should have this.loadCount--; replaced by if(this.loadCount > 0){ this.loadCount--; } Otherwise the comparison to 0 will return false if all assets are loaded (this.loadCount will be -1). I was experiencing this problem on Firefox and it would only work after cleaning the cache. |
it should not happen , since loadCount is taken from toLoad array length . So it should loop and shift always to 0 . |
On the code I had, there was a call to this.loadCount--; on the beginning of the method onAssetLoaded(), so a call to it with this.loadCount == 0 would make this.loadCount evaluate to -1. |
Should be all good now gents :) |
Works fine for me now! Thanks! |
i referring to good for JS small trick. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I have problem with using assetloader ,because when I refresh page it is not calling onComplete function .
The text was updated successfully, but these errors were encountered: