Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. var myImages = ['img/star.png','img/koin.png'];
  2.  
  3. (function() {
  4. var imageCount = myImages.length;
  5. var loadedCount = 0, errorCount = 0;
  6.  
  7. var checkAllLoaded = function() {
  8. if (loadedCount + errorCount == imageCount ) {
  9. // do what you need to do.
  10. console.log("laodedddddd");
  11. that.map = spriteData;
  12. that.image = new Image();
  13. that.image.onload = callback;
  14. that.image.src = 'images/sprites.png'; //dummy
  15. }
  16. };
  17.  
  18. var onload = function() {
  19. loadedCount++;
  20. checkAllLoaded();
  21. }, onerror = function() {
  22. errorCount++;
  23. checkAllLoaded();
  24. };
  25.  
  26. for (var i = 0; i < imageCount; i++) {
  27. var img = new Image();
  28. img.onload = onload;
  29. img.onerror = onerror;
  30. img.src = myImages[i];
  31. }
  32. })();
  33. ///////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement