LoadingState.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. FZ.Game.LoadingState = new (FZ.newClass({
  2. StateName : FZ.StateDefs.GAME_STATE_LOADING,
  3. CUR_UI_DEFS : ["majong_BG", "MAIN_MENU_AND_LOADING_BG", "loading_empty", "loading_full"],
  4. m_test_timer : 0,
  5. m_bar_w : 0,
  6. m_bar_div : null,
  7. // m_bar_num_div : null,
  8. preProcess : function()
  9. {
  10. var div = null;
  11. // loading the resources for the loading state
  12. var mySelf = this;
  13. var index = 0;
  14. var imgInfo = null;
  15. this.createUIs(this.CUR_UI_DEFS);
  16. imgInfo = FZ.getImgInfo(this.CUR_UI_DEFS[3]);
  17. this.m_bar_w = imgInfo.w;
  18. this.m_bar_div = this.m_ui_list[3];
  19. this.m_bar_div.style.overflow = "hidden";
  20. // this.m_bar_div.style.backgroundPosition = "" + (0 - this.m_bar_w) + "px 0px";
  21. this.m_bar_div.style.display = "none";
  22. for (index = 0; index < FZ.IphoneUI.length; index++) {
  23. imgInfo = FZ.IphoneUI[index];
  24. FZ.spriteManager.addResource(imgInfo.name,imgInfo.zOrder,"imgs/" + imgInfo.fileURL,imgInfo.x,imgInfo.y,imgInfo.cols);
  25. }
  26. //FZ.ResourceManager.addResource({"Name":"BGMusic", "Type":"Audio", "URL":FZ.IphoneMusic[0]});
  27. FZ.DivManager.addChild(this.m_main_div);
  28. this.resetTranslate(0);
  29. setTimeout(function() {
  30. mySelf.fade_in.call(mySelf, 2000, 1);
  31. }, 10);
  32. this.m_timer = setTimeout(FZ.Tools.bind(this, this.AIUpdate), 100);
  33. },
  34. postProcess:function() {
  35. FZ.DivManager.removeChild(this.m_main_div);
  36. clearTimeout(this.m_timer);
  37. },
  38. AIUpdate:function(deltaTime)
  39. {
  40. // var str = document.getElementById("strHint");
  41. // this.m_test_timer ++;
  42. // str.value = "" + this.m_test_timer;
  43. var showW = 0;
  44. this.m_timer = setTimeout(FZ.Tools.bind(this, this.AIUpdate), 200);
  45. if(0 !== FZ.ResourceManager.__ResourceCount) {
  46. showW = this.m_bar_w * FZ.ResourceManager.__ResourceLoaded / FZ.ResourceManager.__ResourceCount;
  47. }
  48. this.m_bar_div.style.width = "" + showW + "px";
  49. this.m_bar_div.style.display = "inline";
  50. if (FZ.ResourceManager.isResourceLoaded()) {
  51. //var snd = FZ.ResourceManager.ResourceLib.BGMusic.Resource;
  52. //FZ.Music.set(snd, true);
  53. FZ.GameBase.switchToState(FZ.StateDefs.GAME_STATE_MAINMEN);
  54. }
  55. }
  56. }, FZ.BaseState))();