Main.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. LGlobal.aspectRatio = PORTRAIT;
  2. var GAME_FPS = 30;
  3. init(1000/GAME_FPS, "gamediv", 640, 960, main);
  4. var dataList;
  5. var stageLayer;
  6. var mySoundPlayer;
  7. var gScore = 0;
  8. var gHighScore = 0;
  9. try {
  10. gHighScore = localStorage["fishinglegendHighScore"]?localStorage["fishinglegendHighScore"]:0;
  11. } catch(e) {}
  12. var HOOKS_NUMBER = 3;
  13. var loadData = [
  14. {name : "l_1",path : "style/img_d/l_1.png"}
  15. ,{name : "l_2",path : "style/img_d/l_2.png"}
  16. ,{name : "l_3",path : "style/img_d/l_3.png"}
  17. ,{name : "l_4",path : "style/img_d/l_4.png"}
  18. ,{name : "m_1",path : "style/img_d/m_1.png"}
  19. ,{name : "m_2",path : "style/img_d/m_2.png"}
  20. ,{name : "m_3",path : "style/img_d/m_3.png"}
  21. ,{name : "s_1",path : "style/img_d/s_1.png"}
  22. ,{name : "s_2",path : "style/img_d/s_2.png"}
  23. ,{name : "hook",path : "style/img_d/hook.png"}
  24. ,{name : "score_hook",path : "style/img_d/score_hook.png"}
  25. ,{name : "score_board",path : "style/img_d/score_board.png"}
  26. ,{name : "start_btn",path : "style/img_d/start_btn.png"}
  27. ,{name : "continue_btn",path : "style/img_d/continue_btn.png"}
  28. ,{name : "more_btn",path : "style/img_d/more_btn.png"}
  29. ,{name : "sound_on",path : "style/img_d/sound_on.png"}
  30. ,{name : "sound_off",path : "style/img_d/sound_off.png"}
  31. // ,{name : "face_normal",path : "style/img_d/face_normal.png"}
  32. // ,{name : "face_happy",path : "style/img_d/face_happy.png"}
  33. // ,{name : "face_sad",path : "style/img_d/face_sad.png"}
  34. ,{name : "bubble",path : "style/img_d/bubble.png"}
  35. ,{name : "share",path : "style/img_d/share.jpg"}
  36. ,{name : "logo",path : "style/img_d/logo.png"}
  37. ,{name : "background",path : "style/img_d/background.jpg"}
  38. ,{name : "start_bg",path : "style/img_d/start_bg.jpg"}
  39. ,{type : "js",path : "script/GameBody.js"}
  40. ,{type : "js",path : "script/GameOver.js"}
  41. ,{type : "js",path : "script/FishManager.js"}
  42. ,{type : "js",path : "script/Fish.js"}
  43. ,{type : "js",path : "script/Hook.js"}
  44. ,{type : "js",path : "script/Background.js"}
  45. ,{type : "js",path : "script/Logo.js"}
  46. ,{type : "js",path : "script/Score.js"}
  47. ,{type : "js",path : "script/SoundPlayer.js"}
  48. ];
  49. function main() {
  50. if(LGlobal.canTouch){
  51. LGlobal.stageScale = LStageScaleMode.SHOW_ALL;
  52. LSystem.screen(LStage.FULL_SCREEN);
  53. }
  54. //LGlobal.setDebug(true);
  55. LMouseEventContainer.set(LMouseEvent.MOUSE_DOWN,true);
  56. LMouseEventContainer.set(LMouseEvent.MOUSE_UP,true);
  57. LMouseEventContainer.set(LMouseEvent.MOUSE_MOVE,true);
  58. LLoadManage.load(loadData, function(progress) {
  59. btGame.gameLoading(progress/100);
  60. }, imgLoadComplete);
  61. }
  62. function imgLoadComplete(result){
  63. dataList = result;
  64. stageLayer = new LSprite();
  65. addChild(stageLayer);
  66. mySoundPlayer = new SoundPlayer();
  67. addChild(mySoundPlayer);
  68. // gameStart();
  69. var logo = new Logo();
  70. stageLayer.addChild(logo);
  71. return;
  72. var fps = new FPS();
  73. addChild(fps);
  74. }
  75. function gameStart(){
  76. stageLayer.die();
  77. stageLayer.removeAllChild();
  78. var gameBody = new GameBody();
  79. gameBody.name = "gameBody";
  80. stageLayer.addChild(gameBody);
  81. return;
  82. //debug
  83. var sprite = new LSprite();
  84. addChild(sprite);
  85. sprite.graphics.add(function (){
  86. var c = LGlobal.canvas;
  87. var w = 32,h = 32;
  88. var l1 = LGlobal.width/w;
  89. var l2 = LGlobal.height/h;
  90. c.beginPath();
  91. c.strokeStyle = "#000000";
  92. for(var i=1;i<l1;i++){
  93. c.moveTo(w*i,0);
  94. c.lineTo(w*i,LGlobal.height);
  95. }
  96. for(var i=1;i<l2;i++){
  97. c.moveTo(0,h*i);
  98. c.lineTo(LGlobal.width,h*i);
  99. }
  100. c.stroke();
  101. });
  102. }
  103. function gameOver() {
  104. stageLayer.die();
  105. stageLayer.removeAllChild();
  106. LTweenLite.removeAll();
  107. var gameOvered = new GameOver();
  108. gameOvered.name = "gameOver";
  109. stageLayer.addChild(gameOvered);
  110. return;
  111. }
  112. Util = function(){};
  113. Util.randomN = function(n) {
  114. return Math.floor(Math.random()*n);
  115. }
  116. Util.randomInRange = function(min, max) {
  117. return min+(Math.random()*(max-min));
  118. }
  119. Util.fadeIn = function(object, duration) {
  120. LTweenLite.to(object, duration, {alpha:1, ease:LEasing.Sine.easeIn})
  121. }
  122. Util.fadeOut = function(object, duration, callback) {
  123. LTweenLite.to(object, duration, {alpha:0, ease:LEasing.Sine.easeOut, onComplete:callback});
  124. }
  125. Util.sFloat = function(object, duration) {
  126. originY = object.y;
  127. LTweenLite.to(object, duration, {y:originY-10, loop:true, ease:LEasing.None.easeIn})
  128. .to(object, duration, {y:originY+10, loop:true, ease:LEasing.None.easeIn});
  129. }
  130. Util.correctInRange = function(v, min, max) {
  131. if(v < min) return min;
  132. else if(v > max) return max;
  133. else return v;
  134. }