main.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. var StepBoard = function (a, b) {
  2. this.initialize();
  3. var c = new createjs.Bitmap(queue.getResult(a));
  4. this.addChild(c);
  5. var d = Math.abs(score);
  6. this.stepboardlabel = new createjs.Text(d.toString(), "bold 60px Arial", b);
  7. this.stepboardlabel.textBaseline = "middle";
  8. this.stepboardlabel.x = c.getBounds().width + 30;
  9. this.stepboardlabel.y = c.getBounds().height / 2;
  10. this.addChild(this.stepboardlabel);
  11. };
  12. StepBoard.prototype = new createjs.Container;
  13. StepBoard.prototype.setStepNum = function () {
  14. var a = Math.abs(score);
  15. this.stepboardlabel.text = a.toString();
  16. };
  17. StepBoard.prototype.setStepNum_IncreaseOneStep = function () {
  18. score--;
  19. this.setStepNum();
  20. };
  21. StepBoard.prototype.reSet = function () {
  22. score = 0;
  23. this.setStepNum();
  24. };
  25. function LoadWelComeSceneRes() {
  26. queue.loadManifest({path:RES_DIR + "img/", manifest:[{src:"banner.jpg", id:"banner"}, {src:"help.jpg", id:"help"}, {src:"discription.png", id:"discription"}, {src:"playbtn.png", id:"playbtn"}, {src:"topbtn.png", id:"topbtn"}]}, !1);
  27. }
  28. var WelComeScene = function (a, b, c) {
  29. var d = new createjs.Container;
  30. c.addChild(d);
  31. var e = new createjs.Shape;
  32. e.graphics.f(a).r(0, 0, 640, 960).ef();
  33. d.addChild(e);
  34. a = new createjs.Bitmap(queue.getResult("banner"));
  35. d.addChild(a);
  36. a = new createjs.Bitmap(queue.getResult("help"));
  37. a.setAnchorPoint(0.5, 0.5);
  38. a.x = 320;
  39. a.y = 480;
  40. d.addChild(a);
  41. a = new createjs.Bitmap(queue.getResult("discription"));
  42. a.setAnchorPoint(0.5, 0.5);
  43. a.x = 320;
  44. a.y = 700;
  45. d.addChild(a);
  46. a = new createjs.Bitmap(queue.getResult("playbtn"));
  47. a.setAnchorPoint(0.5, 0.5);
  48. a.x = 155;
  49. a.y = 850;
  50. d.addChild(a);
  51. a.on("mousedown", function (a) {
  52. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
  53. }, a);
  54. a.on("pressup", function (a) {
  55. this.scaleY = this.scaleX = 1;
  56. step = score = 0;
  57. b();
  58. c.removeChild(d);
  59. }, a);
  60. a = new createjs.Bitmap(queue.getResult("topbtn"));
  61. a.setAnchorPoint(0.5, 0.5);
  62. a.x = 485;
  63. a.y = 850;
  64. d.addChild(a);
  65. a.on("mousedown", function (a) {
  66. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
  67. }, a);
  68. a.on("pressup", function (a) {
  69. this.scaleY = this.scaleX = 1;
  70. goHome();
  71. }, a);
  72. c.addChild(d);
  73. };
  74. function LoadGameoverSceneRes() {
  75. queue.loadManifest({path:RES_DIR + "img/", manifest:[{src:"maxscore.png", id:"maxscore"}, {src:"gameoverbg.png", id:"gameoverbg"}, {src:"curscore.png", id:"curscore"}, {src:"sharebtn.png", id:"sharebtn"}, {src:"gameover.png", id:"gameover"}]}, !1);
  76. }
  77. var GameoverNormal = function (a, b, c, d) {
  78. onNewScore(Math.abs(score));
  79. var e = new createjs.Container;
  80. d.addChild(e);
  81. a = new createjs.Bitmap(queue.getResult("gameoverbg"));
  82. e.addChild(a);
  83. a = new createjs.Bitmap(queue.getResult("gameover"));
  84. a.setAnchorPoint(0.5, 0.5);
  85. a.x = 320;
  86. a.y = 190;
  87. e.addChild(a);
  88. a = new createjs.Bitmap(queue.getResult("curscore"));
  89. a.x = 90;
  90. a.y = 290;
  91. e.addChild(a);
  92. a = Math.abs(score);
  93. a = new createjs.Text(a.toString(), "bold 60px Arial", b);
  94. a.textBaseline = "middle";
  95. a.x = 370;
  96. a.y = 320;
  97. e.addChild(a);
  98. a = new createjs.Bitmap(queue.getResult("maxscore"));
  99. a.x = 90;
  100. a.y = 390;
  101. e.addChild(a);
  102. a = Math.abs(best);
  103. b = new createjs.Text(a.toString(), "bold 60px Arial", b);
  104. b.textBaseline = "middle";
  105. b.x = 370;
  106. b.y = 420;
  107. e.addChild(b);
  108. b = new createjs.Bitmap(queue.getResult("playbtn"));
  109. b.setAnchorPoint(0.5, 0.5);
  110. b.x = 185;
  111. b.y = 560;
  112. e.addChild(b);
  113. b.on("mousedown", function (a) {
  114. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
  115. }, b);
  116. b.on("pressup", function (a) {
  117. this.scaleY = this.scaleX = 1;
  118. score = 0;
  119. c();
  120. d.removeChild(e);
  121. }, b);
  122. b = new createjs.Bitmap(queue.getResult("topbtn"));
  123. b.setAnchorPoint(0.5, 0.5);
  124. b.x = 455;
  125. b.y = 560;
  126. e.addChild(b);
  127. b.on("mousedown", function (a) {
  128. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
  129. }, b);
  130. b.on("pressup", function (a) {
  131. this.scaleY = this.scaleX = 1;
  132. goHome();
  133. }, b);
  134. b = new createjs.Bitmap(queue.getResult("sharebtn"));
  135. b.setAnchorPoint(0.5, 0.5);
  136. b.x = 320;
  137. b.y = 700;
  138. e.addChild(b);
  139. b.on("mousedown", function (a) {
  140. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95);
  141. }, b);
  142. b.on("pressup", function (a) {
  143. this.scaleY = this.scaleX = 1;
  144. dp_share();
  145. }, b);
  146. }, qp_a = 12, qp_b = 14, qp_c = 25, qp_d = 27, qp_e = 80, qp_f = 50, qp_g = 0, qp_h = 0, COLOR_RED = "#B2151E", COLOR_GREEN = "#15B26D", COLOR_PURPLE = "#64549D", COLOR_YELLOW = "#FEE789", COLOR_BLUE = "#8ECFF5", COLOR_PINK = "#F6AAC4", qp_i, qp_j, qp_k = null;
  147. function loadResource() {
  148. SCREEN_SHOW_ALL = !0;
  149. qp_l = new createjs.LoadQueue;
  150. var a = new ProgressBar(0.8 * W, 40);
  151. a.regX = a.w / 2;
  152. a.regY = a.h / 2;
  153. a.x = W / 2;
  154. a.y = H / 2;
  155. stage.addChild(a);
  156. queue = qp_l = new createjs.LoadQueue(!1);
  157. qp_l.on("complete", resourceLoadComplete, null, !0);
  158. loadGameData();
  159. USE_NATIVE_SOUND || (IS_NATIVE_ANDROID ? (createjs.Sound.registMySound("do", 0), createjs.Sound.registMySound("re", 2), createjs.Sound.registMySound("me", 4), createjs.Sound.registMySound("fa", 6), createjs.Sound.registMySound("so", 8), createjs.Sound.registMySound("la", 10), createjs.Sound.registMySound("silenttail", 12), qp_l.loadFile({id:"sound", src:RES_DIR + "audio/all.mp3"})) : (createjs.Sound.alternateExtensions = ["ogg"], qp_l.installPlugin(createjs.Sound), qp_l.loadManifest({path:RES_DIR + "audio/", manifest:[{src:"1.mp3", id:"do"}, {src:"2.mp3", id:"re"}, {src:"3.mp3", id:"mi"}, {src:"4.mp3", id:"fa"}, {src:"5.mp3", id:"so"}, {src:"6.mp3", id:"la"}]}, !1)));
  160. LoadWelComeSceneRes();
  161. LoadGameoverSceneRes();
  162. qp_l.loadManifest({path:RES_DIR + "img/", manifest:[{src:"step.png", id:"step"}, {src:"bg.jpg", id:"bg"}, {src:"bluebtn.png", id:"bluebtn"}, {src:"greenbtn.png", id:"greenbtn"}, {src:"pinkbtn.png", id:"pinkbtn"}, {src:"purplebtn.png", id:"purplebtn"}, {src:"redbtn.png", id:"redbtn"}, {src:"yellowbtn.png", id:"yellowbtn"}]}, !1);
  163. a.forQueue(qp_l);
  164. qp_l.load();
  165. }
  166. function resourceLoadComplete(a) {
  167. new WelComeScene("#8de9cb", qp_m, stage);
  168. }
  169. function qp_m() {
  170. var a = [];
  171. a.push(COLOR_RED);
  172. a.push(COLOR_YELLOW);
  173. a.push(COLOR_GREEN);
  174. a.push(COLOR_PURPLE);
  175. a.push(COLOR_BLUE);
  176. a.push(COLOR_PINK);
  177. qp_k = new Qp_n(a);
  178. qp_k.randomMap();
  179. stage.removeChild(qp_j);
  180. qp_j = new createjs.Container;
  181. stage.addChild(qp_j);
  182. a = new createjs.Bitmap(qp_l.getResult("bg"));
  183. qp_j.addChild(a);
  184. qp_o();
  185. qp_i = new StepBoard("step", "#000000");
  186. qp_i.x = 450;
  187. qp_i.y = 20;
  188. stage.addChild(qp_i);
  189. qp_k.initfirstflood();
  190. qp_k.flood(qp_k.m_allitems[0].color, !0);
  191. qp_i.reSet();
  192. a = new createjs.Bitmap(qp_l.getResult("redbtn"));
  193. a.regX = 47;
  194. a.regY = 47;
  195. a.x = 62;
  196. a.y = 880;
  197. qp_j.addChild(a);
  198. a.on("mousedown", function (a) {
  199. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_RED), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  200. }, a);
  201. a.on("pressup", function (a) {
  202. this.scaleY = this.scaleX = 1;
  203. }, a);
  204. a = new createjs.Bitmap(qp_l.getResult("yellowbtn"));
  205. a.regX = 47;
  206. a.regY = 47;
  207. a.x = 165;
  208. a.y = 880;
  209. qp_j.addChild(a);
  210. a.on("mousedown", function (a) {
  211. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_YELLOW), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  212. }, a);
  213. a.on("pressup", function (a) {
  214. this.scaleY = this.scaleX = 1;
  215. }, a);
  216. a = new createjs.Bitmap(qp_l.getResult("purplebtn"));
  217. a.regX = 47;
  218. a.regY = 47;
  219. a.x = 268;
  220. a.y = 880;
  221. qp_j.addChild(a);
  222. a.on("mousedown", function (a) {
  223. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_PURPLE), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  224. }, a);
  225. a.on("pressup", function (a) {
  226. this.scaleY = this.scaleX = 1;
  227. }, a);
  228. a = new createjs.Bitmap(qp_l.getResult("bluebtn"));
  229. a.regX = 47;
  230. a.regY = 47;
  231. a.x = 371;
  232. a.y = 880;
  233. qp_j.addChild(a);
  234. a.on("mousedown", function (a) {
  235. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_BLUE), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  236. }, a);
  237. a.on("pressup", function (a) {
  238. this.scaleY = this.scaleX = 1;
  239. }, a);
  240. a = new createjs.Bitmap(qp_l.getResult("greenbtn"));
  241. a.regX = 47;
  242. a.regY = 47;
  243. a.x = 474;
  244. a.y = 880;
  245. qp_j.addChild(a);
  246. a.on("mousedown", function (a) {
  247. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_GREEN), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  248. }, a);
  249. a.on("pressup", function (a) {
  250. this.scaleY = this.scaleX = 1;
  251. }, a);
  252. a = new createjs.Bitmap(qp_l.getResult("pinkbtn"));
  253. a.regX = 47;
  254. a.regY = 47;
  255. a.x = 577;
  256. a.y = 880;
  257. qp_j.addChild(a);
  258. a.on("mousedown", function (a) {
  259. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_PINK), !0 == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
  260. }, a);
  261. a.on("pressup", function (a) {
  262. this.scaleY = this.scaleX = 1;
  263. }, a);
  264. }
  265. var Qp_n = function (a) {
  266. this.m_colorarray = a;
  267. this.m_allitems = [];
  268. this.m_stepover = !1;
  269. this.m_changeditems = [];
  270. this.m_fxarray = [];
  271. };
  272. Qp_n.prototype.randomMap = function () {
  273. for (var a = 0; a < qp_b; a++) {
  274. for (var b = 0; b < qp_a; b++) {
  275. var c = Math.floor(Math.random() * this.m_colorarray.length);
  276. this.m_allitems[a * qp_a + b] = new Qp_p(this.m_colorarray[c], a, b);
  277. }
  278. }
  279. };
  280. Qp_n.prototype.initfirstflood = function () {
  281. this.m_allitems[0].isflooded = !0;
  282. this.m_changeditems.push(this.m_allitems[0]);
  283. };
  284. Qp_n.prototype.floodX = function (a, b) {
  285. for (var c = 0; c < qp_a; c++) {
  286. this.validij(c, b) && !0 == qp_k.m_allitems[b * qp_a + c].isflooded && b * qp_a + c < qp_a * qp_b - 1 && b * qp_a + c < (b + 1) * qp_a - 1 && !1 == qp_k.m_allitems[b * qp_a + c + 1].isflooded && qp_k.m_allitems[b * qp_a + c + 1].color == a && (this.m_stepover = !1, qp_k.m_allitems[b * qp_a + c + 1].isflooded = !0, this.m_fxarray.push(qp_k.m_allitems[b * qp_a + c + 1]));
  287. }
  288. for (c = qp_a - 1; 0 <= c; c--) {
  289. this.validij(c, b) && !0 == qp_k.m_allitems[b * qp_a + c].isflooded && 0 < b * qp_a + c && b * qp_a + c > b * qp_a && !1 == qp_k.m_allitems[b * qp_a + c - 1].isflooded && qp_k.m_allitems[b * qp_a + c - 1].color == a && (this.m_stepover = !1, qp_k.m_allitems[b * qp_a + c - 1].isflooded = !0, this.m_fxarray.push(qp_k.m_allitems[b * qp_a + c - 1]));
  290. }
  291. };
  292. Qp_n.prototype.floodY = function (a, b) {
  293. for (var c = 0; c < qp_b; c++) {
  294. this.validij(b, c) && !0 == qp_k.m_allitems[c * qp_a + b].isflooded && (c + 1) * qp_a + b < qp_a * qp_b && !1 == qp_k.m_allitems[(c + 1) * qp_a + b].isflooded && qp_k.m_allitems[(c + 1) * qp_a + b].color == a && (this.m_stepover = !1, qp_k.m_allitems[(c + 1) * qp_a + b].isflooded = !0, this.m_fxarray.push(qp_k.m_allitems[(c + 1) * qp_a + b]));
  295. }
  296. for (c = qp_b - 1; 0 <= c; c--) {
  297. this.validij(b, c) && !0 == qp_k.m_allitems[c * qp_a + b].isflooded && 0 < (c - 1) * qp_a + b && !1 == qp_k.m_allitems[(c - 1) * qp_a + b].isflooded && qp_k.m_allitems[(c - 1) * qp_a + b].color == a && (this.m_stepover = !1, qp_k.m_allitems[(c - 1) * qp_a + b].isflooded = !0, this.m_fxarray.push(qp_k.m_allitems[(c - 1) * qp_a + b]));
  298. }
  299. };
  300. Qp_n.prototype.flood = function (a, b) {
  301. for (this.m_fxarray = []; !0 != this.m_stepover; ) {
  302. this.m_stepover = !0;
  303. for (var c = 0; c < Math.max(qp_a, qp_b); c++) {
  304. this.floodY(a, c);
  305. }
  306. for (c = 0; c < Math.max(qp_a, qp_b); c++) {
  307. this.floodX(a, c);
  308. }
  309. }
  310. 0 < this.m_fxarray.length && (qp_q(this.m_fxarray, a, b), qp_i.setStepNum_IncreaseOneStep());
  311. this.m_stepover = !1;
  312. };
  313. Qp_n.prototype.validij = function (a, b) {
  314. return 0 > a || a >= qp_a || 0 > b || b >= qp_b ? !1 : !0;
  315. };
  316. Qp_n.prototype.get1Dindex = function (a, b) {
  317. return this.validij(a, b) ? b * qp_a + a : -1;
  318. };
  319. Qp_n.prototype.isGameOver = function () {
  320. return qp_k.m_changeditems.length >= qp_a * qp_b ? !0 : !1;
  321. };
  322. function qp_o() {
  323. qp_r(qp_k.m_allitems);
  324. }
  325. function qp_q(a, b, c) {
  326. for (var d = 0; d < a.length; d++) {
  327. qp_k.m_changeditems.push(a[d]);
  328. }
  329. for (d = 0; d < qp_k.m_changeditems.length; d++) {
  330. a = (qp_k.m_changeditems[d].indexj + qp_k.m_changeditems[d].indexi + 1) * qp_c, createjs.Tween.get(qp_k.m_changeditems[d].img).to({alpha:1}, a).call(function () {
  331. this.graphics.clear();
  332. this.graphics.f(b).r(0, 0, qp_f, qp_f);
  333. }).to({alpha:1}, 0);
  334. }
  335. !0 != c && qp_s(b);
  336. }
  337. function qp_r(a) {
  338. for (a = 0; a < qp_b; a++) {
  339. for (var b = 0; b < qp_a; b++) {
  340. var c = (a + b + 1) * qp_c, d = qp_k.m_allitems[a * qp_a + b].img;
  341. d.alpha = 0;
  342. createjs.Tween.get(d).to({alpha:0}, c).to({alpha:1}, 100);
  343. d.x = qp_d + (qp_f + qp_g) * b + qp_f / 2 + qp_h - b;
  344. d.y = qp_e + (qp_f + qp_g) * a + qp_f / 2 + qp_h - a;
  345. qp_j.addChild(d);
  346. }
  347. }
  348. }
  349. function qp_s(a) {
  350. a == COLOR_RED && createjs.Sound.play("do", !0);
  351. a == COLOR_YELLOW && createjs.Sound.play("re", !0);
  352. a == COLOR_PURPLE && createjs.Sound.play("mi", !0);
  353. a == COLOR_BLUE && createjs.Sound.play("fa", !0);
  354. a == COLOR_GREEN && createjs.Sound.play("so", !0);
  355. a == COLOR_PINK && createjs.Sound.play("la", !0);
  356. }
  357. var Qp_p = function (a, b, c) {
  358. this.color = this.m_color = a;
  359. this.isflooded = this.m_isflooded = !1;
  360. this.indexi = b;
  361. this.indexj = c;
  362. this.img = this.m_img = new createjs.Shape;
  363. this.m_img.graphics.f(a).r(0, 0, qp_f, qp_f).ef();
  364. this.m_img.regX = qp_f / 2;
  365. this.m_img.regY = qp_f / 2;
  366. this.floodGird = function () {
  367. this.m_isflooded = !0;
  368. };
  369. this.fillcolor = function (a) {
  370. };
  371. };
  372. Qp_p.prototype = new createjs.Container;