main.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. H = 960;
  2. function qp_a(a) {}
  3. var qp_b = 30,
  4. qp_c, qp_d = 5,
  5. qp_e = 3,
  6. qp_f = qp_e,
  7. qp_g = 420,
  8. qp_h = 0,
  9. qp_i = [],
  10. qp_j = 20,
  11. qp_k = 0,
  12. qp_l,
  13. qp_m = 0,
  14. qp_n = 0,
  15. qp_o = 0;
  16. function qp_p() {
  17. qipaStage.stage.arrow.visible = !0;
  18. qp_q = qipaApp.score = 0;
  19. qp_n = qp_b;
  20. qp_m = -1;
  21. qipaStage.stage.num.txt.text = qp_n + '"';
  22. qp_k = 0;
  23. qp_o = 1;
  24. qipaApp.onGameStarted()
  25. }
  26. function qp_r() {
  27. qipaStage.stage.splash.visible = !0
  28. }
  29. function qp_s() {
  30. qipaStage.stage.arrow.visible = !1;
  31. qp_m = 0
  32. }
  33. function qp_t() {
  34. qp_o = 3;
  35. qp_l = setTimeout(function() {
  36. window.clearTimeout(qp_l)
  37. },
  38. 900);
  39. qp_u();
  40. qipaApp.onNewScore(qipaApp.score);
  41. qipaApp.onGameOver();
  42. qipaStage.stage.gameover.visible = !0;
  43. qipaStage.stage.gameover.refresh()
  44. }
  45. function qp_v(a) {
  46. IS_ANDROID && (createjs.Sound.registMySound("count", 0), createjs.Sound.registMySound("silenttail", 0.25));
  47. qp_w();
  48. qp_u()
  49. }
  50. function Qp_x() {
  51. this.initialize();
  52. this.bg = new createjs.Shape;
  53. this.bg.graphics.beginFill("#559966").drawRect(0, 0, W, H);
  54. this.addChild(this.bg);
  55. this.label = new createjs.Bitmap(qipaStage.queue.getResult("splashtitle"));
  56. this.label.x = (W - this.label.getBounds().width) / 2;
  57. this.label.y = 100;
  58. this.addChild(this.label);
  59. this.start = new createjs.Bitmap(qipaStage.queue.getResult("mb0"));
  60. this.start.y = H - 300;
  61. this.start.x = (W - this.start.getBounds().width) / 2;
  62. this.addChild(this.start);
  63. this.arrow = new createjs.Bitmap(qipaStage.queue.getResult("starttip"));
  64. this.arrow.y = H - 400;
  65. this.arrow.x = (W - this.arrow.getBounds().width) / 2;
  66. this.addChild(this.arrow);
  67. var a, b;
  68. this.start.on("mousedown",
  69. function(c) {
  70. 0 == qp_o && (a = c.localY, b = H - 300)
  71. });
  72. this.start.on("pressmove",
  73. function(c) {
  74. 0 == qp_o && SplashPressmoveEvent(c.localY - a, b)
  75. });
  76. this.start.on("pressup",
  77. function(b) {
  78. 0 == qp_o && 30 > a - b.localY && (createjs.Sound.play("count", !0), createjs.Tween.get(qipaStage.stage.splash.start).to({
  79. y: -H
  80. },
  81. 400).call(function(a) {
  82. qipaStage.stage.splash.arrow.visible = !1;
  83. qp_p();
  84. qipaStage.stage.splash.visible = !1
  85. }))
  86. })
  87. }
  88. Qp_x.prototype = new createjs.Container;
  89. function SplashPressmoveEvent(a, b) {
  90. qipaStage.stage.splash.start.y + a < b && (qipaStage.stage.splash.start.y += a)
  91. }
  92. function qp_w() {
  93. var a = new createjs.Shape;
  94. a.graphics.beginFill("#559966").drawRect(0, 0, W, H);
  95. qipaStage.stage.addChild(a);
  96. var b = new createjs.Shape;
  97. b.graphics.beginFill("white").rect(0, 200, W, H);
  98. a.hitArea = b;
  99. var c = 0,
  100. d = 0;
  101. a.on("mousedown",
  102. function(a) {
  103. IS_TOUCH && a.nativeEvent instanceof MouseEvent || 2 != qp_o && 1 != qp_o || (c = a.localY, d = qipaStage.stage.player.m[qp_f].y)
  104. });
  105. a.on("pressmove",
  106. function(a) {
  107. IS_TOUCH && a.nativeEvent instanceof MouseEvent || (1 == qp_o && (qp_s(), qp_o = 2), 2 == qp_o && (qipaStage.stage.player.m[qp_f].visible = !0, qipaStage.stage.player.m[qp_f].y += (a.localY - c) / 1.5))
  108. });
  109. var f = 0;
  110. a.on("pressup",
  111. function(a) {
  112. IS_TOUCH && a.nativeEvent instanceof MouseEvent || 2 != qp_o || (50 < c - a.localY ? (a = (new Date).getTime(), 0 < qp_i.length && qp_i[qp_i.length - 1] + 50 > a ? qp_a("WARNING: Too fast! maybe engine error.") : (f = qp_y(a), f <= qp_j ? (qp_k++, qipaApp.score += 100, qipaStage.stage.player.playAnimation(qipaStage.stage.player.m[qp_f]), createjs.Sound.play("count", !0)) : (qp_i.length--, qp_a("WARN: " + f)))) : (qp_z(d), qipaStage.stage.player.m[qp_f].visible = !1))
  113. });
  114. qp_c = [];
  115. for (a = 0; a <= qp_e; a++) for (qp_c[a] = [], b = 0; b < qp_d; b++) {
  116. var e = new createjs.Bitmap(qipaStage.queue.getResult("d0"));
  117. e.regX = e.getBounds().width / 2;
  118. e.regY = e.getBounds().height / 2;
  119. e.x = genRandom(W);
  120. e.y = -H / 2 + genRandom(H);
  121. e.visible = !1;
  122. qp_c[a].push(e);
  123. qipaStage.stage.addChild(qp_c[a][b])
  124. }
  125. qipaStage.stage.player = new Qp_A;
  126. qipaStage.stage.addChild(qipaStage.stage.player);
  127. qipaStage.stage.num = new Qp_B;
  128. qipaStage.stage.num.y = 30;
  129. qipaStage.stage.addChild(qipaStage.stage.num);
  130. qipaStage.stage.arrow = new createjs.Bitmap(qipaStage.queue.getResult("starttip"));
  131. qipaStage.stage.arrow.x = (W - qipaStage.stage.arrow.getBounds().width) / 2;
  132. qipaStage.stage.arrow.y = 290;
  133. qipaStage.stage.arrow.visible = !1;
  134. qipaStage.stage.addChild(qipaStage.stage.arrow);
  135. qipaStage.stage.gameover = new Qp_C;
  136. qipaStage.stage.gameover.x = 0;
  137. qipaStage.stage.gameover.y = 260;
  138. qipaStage.stage.gameover.visible = !1;
  139. qipaStage.stage.addChild(qipaStage.stage.gameover);
  140. qipaStage.stage.splash = new Qp_x;
  141. qipaStage.stage.addChild(qipaStage.stage.splash);
  142. setInterval(qp_D, 1E3);
  143. createjs.Ticker.addEventListener("tick",
  144. function(a) {
  145. 0 <= qp_m && (qp_m += a.delta, a = 30 - parseInt(qp_m / 1E3), a != qp_n && (qp_n = a, qipaStage.stage.num.txt.text = qp_n + '"'), 0 >= qp_n && (qp_m = -1, qp_t()));
  146. qipaStage.stage.num.sum.text = "\uffe5" + qipaApp.score
  147. })
  148. }
  149. function Qp_A() {
  150. this.initialize();
  151. this.mb = new createjs.Bitmap(qipaStage.queue.getResult("mb0"));
  152. this.mb.regX = this.mb.getBounds().width / 2;
  153. this.mb.regY = this.mb.getBounds().height / 2;
  154. this.mb.y = qp_g;
  155. this.x = W / 2;
  156. this.y = H / 2 - 150;
  157. this.addChild(this.mb);
  158. this.m = [];
  159. for (var a = 0; 3 >= a; a++) this.m[a] = new createjs.Bitmap(qipaStage.queue.getResult("m0")),
  160. this.m[a].regX = this.m[a].getBounds().width / 2,
  161. this.m[a].regY = this.m[a].getBounds().height / 2,
  162. this.m[a].y = qp_g,
  163. this.m[a].visible = !1,
  164. this.addChild(this.m[a]);
  165. for (a = 0; a <= qp_e; a++) this.m[a].image = qipaStage.queue.getResult("m0");
  166. for (a = 0; a < qp_c.length; a++) for (var b = 0; b < qp_c[a].length; b++) qp_c[a][b].image = qipaStage.queue.getResult("d0")
  167. }
  168. Qp_A.prototype = new createjs.Container;
  169. Qp_A.prototype.playAnimation = function(a) {
  170. a.visible = !0;
  171. createjs.Tween.get(a).to({
  172. scaleX: 0.5,
  173. scaleY: 0.5,
  174. y: -H
  175. },
  176. 300).to({
  177. visible: !1,
  178. y: qp_g,
  179. scaleX: 1,
  180. scaleY: 1
  181. },
  182. 0);
  183. 0 < qp_f ? qp_f--:qp_f = qp_e
  184. };
  185. function genRandom(a) {
  186. return parseInt(Math.random() * a)
  187. }
  188. function qp_E(a) {
  189. return 10
  190. }
  191. var qp_F = 0;
  192. function qp_D() {
  193. for (var a = 0; a < qp_d; a++) qp_c[qp_F][a].visible = !0,
  194. createjs.Tween.get(qp_c[qp_F][a]).to({
  195. y: H + qp_c[qp_F][a].getBounds().height / 2 + 100,
  196. rotation: 720 + genRandom(400),
  197. x: genRandom(W)
  198. },
  199. 1E3 + genRandom(800)).to({
  200. visible: !1
  201. },
  202. 10).to({
  203. x: genRandom(W),
  204. y: -H / 2 + genRandom(H / 2),
  205. rotation: 0
  206. },
  207. 10);
  208. qp_F < qp_e ? qp_F++:qp_F = 0
  209. }
  210. function qp_z(a) {
  211. var b = Math.abs(qipaStage.stage.player.m[qp_f] - a);
  212. createjs.Tween.get(qipaStage.stage.player.m[qp_f]).to({
  213. y: a
  214. },
  215. 20 * b)
  216. }
  217. function Qp_C() {
  218. this.initialize();
  219. var a = new createjs.Shape,
  220. b = qipaStage.queue.getResult("dlgbg");
  221. a.setBounds(0, 0, W, b.height);
  222. a.graphics.bf(b).r(0, 0, W, b.height);
  223. this.addChild(a);
  224. b = new createjs.Bitmap(qipaStage.queue.getResult("start"));
  225. b.x = 40;
  226. b.y = a.y + a.getBounds().height - 160;
  227. b.on("click",
  228. function(a) {
  229. qp_p();
  230. qipaStage.stage.gameover.visible = !1
  231. });
  232. var c = new createjs.Bitmap(qipaStage.queue.getResult("rank"));
  233. c.x = W / 2;
  234. c.y = b.y;
  235. c.regX = c.getBounds().width / 2;
  236. c.on("click",
  237. function(a) {
  238. clickMore();
  239. });
  240. var d = new createjs.Bitmap(qipaStage.queue.getResult("share"));
  241. d.x = W - 40;
  242. d.y = b.y;
  243. d.regX = c.getBounds().width;
  244. d.on("click",
  245. function(a) {
  246. IS_TOUCH && a.nativeEvent instanceof MouseEvent || dp_share()
  247. });
  248. this.addChild(b);
  249. this.addChild(c);
  250. this.addChild(d);
  251. this.scoreText = new createjs.Text("", "bold 50px Arial", "#fff");
  252. this.scoreText.textAlign = "center";
  253. this.scoreText.x = W / 2;
  254. this.scoreText.y = a.y + 50;
  255. this.addChild(this.scoreText);
  256. this.shareText = new createjs.Text("", "38px Arial", "#eee");
  257. this.shareText.textAlign = "center";
  258. this.shareText.x = W / 2;
  259. this.shareText.y = this.scoreText.y + 95;
  260. this.addChild(this.shareText)
  261. }
  262. Qp_C.prototype = new createjs.Container;
  263. Qp_C.prototype.refresh = function() {
  264. this.scoreText.text = "\uffe5" + qipaApp.score;
  265. this.shareText.text = 0 < qipaApp.score ? qipaShare.desc.replace("\u6bd4", "\n\u6bd4").replace("\u6211\u662f", "\n\u6211\u662f") : ""
  266. };
  267. function Qp_B() {
  268. this.initialize();
  269. this.tmbg = new createjs.Bitmap(qipaStage.queue.getResult("tmbg"));
  270. this.tmbg.x = (W - this.tmbg.getBounds().width) / 2;
  271. this.tmbg.y = 30;
  272. this.addChild(this.tmbg);
  273. this.sum = new createjs.Text("\uffe5" + qipaApp.score, "bold 46px Arial", "yellow");
  274. this.sum.textAlign = "center";
  275. this.sum.textBaseline = "middle";
  276. this.sum.x = W / 2;
  277. this.sum.y = this.tmbg.y + this.tmbg.getBounds().height / 2;
  278. this.addChild(this.sum);
  279. this.tmbg1 = new createjs.Bitmap(qipaStage.queue.getResult("tmbg"));
  280. this.tmbg1.scaleX = 0.7;
  281. this.tmbg1.x = (W - 0.7 * this.tmbg.getBounds().width) / 2;
  282. this.tmbg1.y = this.tmbg.y + this.tmbg.getBounds().height + 15;
  283. this.addChild(this.tmbg1);
  284. this.tmicon = new createjs.Bitmap(qipaStage.queue.getResult("tmicon"));
  285. this.tmicon.x = this.tmbg1.x + 14;
  286. this.tmicon.y = this.tmbg1.y + 14;
  287. this.addChild(this.tmicon);
  288. this.txt = new createjs.Text(qp_n + '"', "bold 44px Arial", "white");
  289. this.txt.textAlign = "center";
  290. this.txt.textBaseline = "middle";
  291. this.txt.x = W / 2 + this.tmicon.getBounds().width / 2;
  292. this.txt.y = this.tmbg1.y + this.tmbg1.getBounds().height / 2;
  293. this.addChild(this.txt)
  294. }
  295. Qp_B.prototype = new createjs.Container;
  296. function qp_y(a) {
  297. var b = 0;
  298. if (0 != qp_i.length) {
  299. var c;
  300. for (c = 0; c < qp_i.length && !(qp_i[c] > a - 1E3); c++);
  301. for (var b = qp_i.length - c,
  302. d = c; d < qp_i.length; d++) qp_i[d - c] = qp_i[d];
  303. qp_i.length -= c
  304. }
  305. qp_i.push(a);
  306. return parseInt(b)
  307. }
  308. function qp_u() {
  309. qipaShare.title = "\u6570\u94b1\u6570\u5230\u624b\u62bd\u7b4b\uff01\u4f60\u662f\u6570\u94b1\u9ad8\u624b\u5417\uff1f";
  310. if (0 == qipaApp.score) qipaShare.desc = qipaShare.title;
  311. else {
  312. var a = parseInt(Math.sqrt(1E4 * qipaApp.score / 17E3));
  313. 99 < a && (a = "99.9");
  314. qipaShare.title = "\u6211\u6570\u4e86\uffe5" + qipaApp.score + "\uff0c\u6bd4" + a + "%\u7684\u4eba\u6709\u94b1\uff01\u6211\u662f" + (5E3 > qipaApp.score ? "\u5c4c\u4e1d": 1E4 > qipaApp.score ? "\u8d2b\u519c": 15E3 > qipaApp.score ? "\u5bcc\u519c": 2E4 > qipaApp.score ? "\u571f\u8c6a": 25E3 > qipaApp.score ? "\u7164\u8001\u677f": "\u8d44\u672c\u5bb6") + "\u3002"
  315. }
  316. dp_submitScore(qipaApp.score);
  317. }
  318. var _cfg = {
  319. startFunc: qp_v,
  320. img: {
  321. path: "img/",
  322. manifest: [{
  323. src: "m0.png",
  324. id: "m0"
  325. },
  326. {
  327. src: "mb0.png",
  328. id: "mb0"
  329. },
  330. {
  331. src: "d0.png",
  332. id: "d0"
  333. },
  334. {
  335. src: "starttip.png",
  336. id: "starttip"
  337. },
  338. {
  339. src: "tmbg.png",
  340. id: "tmbg"
  341. },
  342. {
  343. src: "splashtitle.png",
  344. id: "splashtitle"
  345. },
  346. {
  347. src: "tmicon.png",
  348. id: "tmicon"
  349. },
  350. {
  351. src: "start.png",
  352. id: "start"
  353. },
  354. {
  355. src: "rank.png",
  356. id: "rank"
  357. },
  358. {
  359. src: "share.png",
  360. id: "share"
  361. },
  362. {
  363. src: "dlgbg.png",
  364. id: "dlgbg"
  365. }]
  366. },
  367. audio: {
  368. path: "audio/",
  369. manifest: [{
  370. src: "count.mp3",
  371. id: "count"
  372. }]
  373. }
  374. };
  375. qipaStage.init(_cfg);