index.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970
  1. var Main = {};
  2. btGame.makePublisher(Main);
  3. Main.width = 640;
  4. Main.height = 1136;
  5. Main.floorLine = 820;
  6. Main.guideDistance = Main.width;
  7. Main.debug = true;
  8. Main.bjyFlag = false;
  9. Main.minAngle = 5;
  10. Main.maxAngle = 20;
  11. Main.randomAngle = 2;
  12. Main.fallingTime = 2500;
  13. Main.speed = 1000;
  14. Main.checkT = 0;
  15. Main.visibleDistance = 250;
  16. Main.maxScore = (window.localStorage && +localStorage["penguinMaxScore"]) || 0;
  17. Main.gameTimes = (window.localStorage && +localStorage["gameTimes"]) || 0;
  18. Main.nowScore = 0;
  19. Main.remainCount = null;
  20. Main.wordCount = null;
  21. Main.fps = 40;
  22. Main.user_balloon_id = 0;
  23. Main.sendFlag = false;
  24. Main.sendOverFlag = false;
  25. Main.resultCode = 0;
  26. Main.beginT = 0;
  27. Main.gameT = 30 * 1000;
  28. Main.rewardId = -1;
  29. Main.eggArr = [];
  30. Main.eggIndex = 0;
  31. Main.eggMax = 8;
  32. Main.firstFlag = true;
  33. Main.checkTouch = false;
  34. Main.RightWingRFlag = Main.rotationStep = 20;
  35. var Resource; ~
  36. function (b) {
  37. b.load = function () {
  38. if (b.queue != null) {
  39. return
  40. }
  41. b.queue = new createjs.LoadQueue(false);
  42. b.queue.addEventListener("progress",
  43. function (c) {
  44. btGame.gameLoading(c.loaded)
  45. });
  46. b.queue.addEventListener("complete",
  47. function (c) {
  48. Main.log("finish", c)
  49. });
  50. b.queue.addEventListener("error",
  51. function (c) {
  52. btGame.gameLoading(0.1, c.text)
  53. });
  54. b.queue.loadFile("images/11.jpg");
  55. b.queue.loadFile("images/02.png");
  56. b.queue.loadFile("images/33.png");
  57. b.queue.loadFile("images/04.png");
  58. b.queue.loadFile("images/55.png");
  59. b.queue.loadFile("images/06.png");
  60. b.queue.loadFile("images/07.png");
  61. b.queue.loadFile("images/08.png");
  62. b.queue.loadFile("images/09.png");
  63. b.queue.loadFile("images/10.png");
  64. b.queue.loadFile("images/35.jpg");
  65. b.queue.loadFile("images/23.png");
  66. b.queue.loadFile("images/13.png");
  67. b.queue.loadFile("images/36.png");
  68. b.queue.loadFile("images/39.png");
  69. b.queue.loadFile("images/25.png");
  70. b.queue.loadFile("images/24.png");
  71. b.queue.loadFile("images/37.png");
  72. b.queue.loadFile("images/61.png");
  73. b.queue.loadFile("images/60.png");
  74. b.queue.loadFile("images/65.png")
  75. };
  76. b.get = function (c) {
  77. return b.queue.getResult(c)
  78. }
  79. }(Resource || (Resource = {}));
  80. Main.log = function () {
  81. Main.debug && console.log(arguments)
  82. };
  83. Main.startGame = function () {
  84. if (!Main.beginContainer) {
  85. Main.beginContainer = new createjs.Container()
  86. } else {
  87. Main.beginContainer.removeAllEventListeners();
  88. Main.beginContainer.removeAllChildren()
  89. }
  90. var d = Main.beginContainer;
  91. var h = new createjs.Bitmap(Resource.get("images/35.jpg"));
  92. d.addChild(h);
  93. var b = new createjs.Bitmap(Resource.get("images/06.png"));
  94. var c = b.getBounds();
  95. b.x = (Main.width - c.width) / 2;
  96. b.y = 370;
  97. b.cursor = "pointer";
  98. b.addEventListener("click",
  99. function () {
  100. Main.getGameBeginMsg()
  101. });
  102. d.addChild(b);
  103. if (gamef.platType == PLAT_BJY || gamef.platType == PLAT_WX) {
  104. var f = new createjs.Bitmap(Resource.get("images/07.png"));
  105. f.x = b.x;
  106. f.y = b.y + 110;
  107. f.cursor = "pointer";
  108. f.addEventListener("click",
  109. function () {
  110. torank()
  111. });
  112. d.addChild(f);
  113. var k = new createjs.Bitmap(Resource.get("images/09.png"));
  114. var c = k.getBounds();
  115. k.x = (Main.width - c.width) / 2;
  116. k.y = f.y + 110;
  117. k.cursor = "pointer";
  118. k.addEventListener("click",
  119. function () {
  120. Main.showHongbao()
  121. });
  122. d.addChild(k)
  123. } else {
  124. var i = new createjs.Bitmap(Resource.get("images/61.png"));
  125. i.x = b.x;
  126. i.y = b.y + 110;
  127. i.cursor = "pointer";
  128. i.addEventListener("click",
  129. function () {
  130. Main.showGonglue()
  131. });
  132. d.addChild(i);
  133. var g = new createjs.Bitmap(Resource.get("images/60.png"));
  134. var c = g.getBounds();
  135. g.x = (Main.width - c.width) / 2;
  136. g.y = i.y + 110;
  137. g.cursor = "pointer";
  138. g.addEventListener("click",
  139. function () {
  140. downLoadZhangDa()
  141. });
  142. d.addChild(g)
  143. }
  144. Main.addShareBtn(d, 20, 590 + 200);
  145. var j = new createjs.Bitmap(Resource.get("images/37.png"));
  146. j.x = 98;
  147. j.y = 292;
  148. Main.remainCountBg = j;
  149. d.addChild(j);
  150. var m = new createjs.Text("", "20px Arial Black", "#FFffff");
  151. m.x = j.x + 60;
  152. m.y = j.y + 20;
  153. m.text = "你的剩余\n游戏次数还";
  154. m.textAlign = "center";
  155. d.addChild(m);
  156. Main.remainCountTipsTxt = m;
  157. var m = new createjs.Text("", "20px Arial Black", "#FFffff");
  158. m.x = j.x + 20;
  159. m.y = j.y + 70;
  160. m.text = "有9次";
  161. d.addChild(m);
  162. Main.remainCountTxt = m;
  163. var m = new createjs.Text("", "24px Arial Black", "#FFffff");
  164. m.x = 422;
  165. m.y = 610;
  166. m.text = "";
  167. m.textBaseline = "middle";
  168. m.textAlign = "center";
  169. d.addChild(m);
  170. Main.wordCountTxt = m;
  171. Main.stage.addChild(d);
  172. var e = 300;
  173. var l = 400;
  174. Main.showTimes()
  175. };
  176. Main.getSharePercent = function (b) {
  177. if (b > 270) {
  178. return 99.99
  179. } else {
  180. if (b > 260) {
  181. return 99.97
  182. } else {
  183. if (b > 250) {
  184. return 99.96
  185. } else {
  186. if (b > 240) {
  187. return 99.95
  188. } else {
  189. if (b > 230) {
  190. return 99.94
  191. } else {
  192. if (b > 220) {
  193. return 99.93
  194. } else {
  195. if (b > 210) {
  196. return 99.91
  197. } else {
  198. if (b > 200) {
  199. return 99.8
  200. } else {
  201. if (b > 190) {
  202. return 99.5
  203. } else {
  204. if (b > 180) {
  205. return 99.3
  206. } else {
  207. if (b > 170) {
  208. return 99
  209. } else {
  210. if (b > 160) {
  211. return 98
  212. } else {
  213. if (b > 150) {
  214. return 97
  215. } else {
  216. if (b > 140) {
  217. return 96
  218. } else {
  219. if (b > 130) {
  220. return 95
  221. } else {
  222. if (b > 120) {
  223. return 90
  224. } else {
  225. if (b > 110) {
  226. return 85
  227. } else {
  228. if (b > 100) {
  229. return 80
  230. } else {
  231. if (b > 90) {
  232. return 70
  233. } else {
  234. if (b > 80) {
  235. return 50
  236. } else {
  237. if (b > 60) {
  238. return 40
  239. } else {
  240. if (b > 50) {
  241. return 30
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. }
  264. return 0
  265. };
  266. Main.addShareBtn = function (c, e, d) {
  267. if (gamef.platType != PLAT_BJY && gamef.platType != PLAT_WX) {
  268. return
  269. }
  270. var g = new createjs.Bitmap(Resource.get("images/10.png"));
  271. g.setTransform(e, d);
  272. g.cursor = "pointer";
  273. g.addEventListener("click",
  274. function () {
  275. Main.showGonglue()
  276. });
  277. //if (Main.firstFlag == true) {
  278. // gamef.shareData.content = "我参加了掌上大学圣诞母鸡活动,快来帮我增加体力拿奖品吧!"
  279. //} else {
  280. // gamef.shareData.content = "靠,我让圣诞母鸡生了" + Main.nowScore + "个蛋," + "Ta没体力了,快来帮我一下!"
  281. //}
  282. c.addChild(g);
  283. var f = 205;
  284. if (Main.bjyFlag == true) {
  285. var h = 1;
  286. var b = false;
  287. if (L.os == "ios") {
  288. b = L.versionCheck("1.9.4")
  289. } else {
  290. if (L.os == "android") {
  291. b = L.versionCheck("1.9.3")
  292. }
  293. }
  294. if (!b) {
  295. var i = new createjs.Bitmap(Resource.get("images/36.png"));
  296. i.setTransform(e + h * f, d);
  297. i.addEventListener("click",
  298. function () {
  299. var l = gamef.shareData;
  300. gamef.share()
  301. });
  302. c.addChild(i);
  303. h++;
  304. var k = new createjs.Bitmap(Resource.get("images/39.png"));
  305. k.setTransform(e + h * f, d);
  306. k.addEventListener("click",
  307. function () {
  308. var l = gamef.shareData;
  309. L.share(l.content, l.content, l.link, l.imgurl, 1)
  310. });
  311. c.addChild(k)
  312. } else {
  313. h = 2;
  314. var j = new createjs.Bitmap(Resource.get("images/39.png"));
  315. j.setTransform(e + h * f, d);
  316. j.addEventListener("click",
  317. function () {
  318. var l = gamef.shareData;
  319. gamef.share()
  320. });
  321. c.addChild(j)
  322. }
  323. }
  324. if (gamef.platType == PLAT_WX) {
  325. h = 2;
  326. var j = new createjs.Bitmap(Resource.get("images/39.png"));
  327. j.setTransform(e + h * f, d);
  328. j.addEventListener("click",
  329. function () {
  330. var l = gamef.shareData;
  331. gamef.share()
  332. });
  333. c.addChild(j)
  334. }
  335. };
  336. Main.showGonglue = function () {
  337. JQMethod.game_Strategy()
  338. };
  339. Main.clearGonglue = function () {
  340. if (Main.gonglueContainer) {
  341. Main.gonglueContainer.removeAllEventListeners();
  342. Main.gonglueContainer.removeAllChildren()
  343. }
  344. };
  345. Main.getGameBeginMsg = function () {
  346. if (Main.sendFlag == true) {
  347. return
  348. }
  349. Main.sendFlag = true;
  350. this.resultCode = -1;
  351. this.sendOverFlag = -1;
  352. this.countNum = 0;
  353. var b = null;
  354. if (gamef.platType == PLAT_BJY) {
  355. b = "webgame/start?type=" + gamef.gameid
  356. } else {
  357. if (gamef.platType == PLAT_WX) {
  358. b = WXDOMAIN + "wxgame/start?type=" + gamef.gameid + "&open_id=" + gamef.open_id
  359. }
  360. }
  361. gamef.start(b, "GET", this.getGameBeginBack)
  362. };
  363. Main.getGameBeginBack = function (g, d, e) {
  364. var f = Main;
  365. var c = e;
  366. if (typeof e === "string") {
  367. c = JSON.parse(e)
  368. }
  369. Main.sendFlag = false;
  370. this.resultCode = c.status;
  371. if (c.status == 0) {
  372. f.user_balloon_id = c.userBallonInfo.user_balloon_id;
  373. if (Main.firstFlag == true) {
  374. Main.beginShowMovie()
  375. } else {
  376. Main.repiyerMovie()
  377. }
  378. } else {
  379. if (c.status == 2014) {
  380. toast("次数用完");
  381. try {
  382. JQMethod.messageBox_show(8)
  383. } catch (b) { }
  384. } else {
  385. if (c.status == 2) {
  386. toast("游戏不存在")
  387. } else {
  388. if (c.status == 2017) {
  389. toast("用户不存在")
  390. } else {
  391. toast("无法连接到网络,请检查网络设置后再试")
  392. }
  393. }
  394. }
  395. }
  396. };
  397. Main.checkBJY = function () {
  398. if (gamef.platType == PLAT_BJY) {
  399. Main.bjyFlag = true
  400. } else {
  401. Main.bjyFlag = false
  402. }
  403. };
  404. Main.beginShowMovie = function () {
  405. createjs.Tween.get(Main.beginContainer, {
  406. loop: false
  407. }).to({
  408. alpha: 0
  409. },
  410. 300).call(function () {
  411. Main.initGame()
  412. })
  413. };
  414. Main.repiyerMovie = function () {
  415. createjs.Tween.get(Main.endContainer, {
  416. loop: false
  417. }).to({
  418. y: -Main.height,
  419. alpha: 0
  420. },
  421. 500, createjs.Ease.quintInOut).call(function () {
  422. Main.endContainer.alpha = 1;
  423. Main.endContainer.removeAllEventListeners();
  424. Main.endContainer.removeAllChildren();
  425. Main.reset.replay()
  426. })
  427. };
  428. // ih5game.setShare({
  429. // desc: "圣诞快乐~还没收到圣诞礼物的就赶快来玩吧!~"
  430. // });
  431. Main.endGame = function (b) {
  432. if (!Main.endContainer) {
  433. Main.endContainer = new createjs.Container();
  434. Main.stage.addChild(Main.endContainer)
  435. } else {
  436. Main.endContainer.removeAllEventListeners();
  437. Main.endContainer.removeAllChildren()
  438. }
  439. Main.firstFlag = false;
  440. var d = Main.endContainer;
  441. d.alpha = !0;
  442. var e = new createjs.Shape;
  443. e.graphics.beginFill("rgb(225, 152, 37").drawRect(0, 0, Main.width, Main.height);
  444. e.alpha = 0.4;
  445. d.addChild(e);
  446. var p = new createjs.Bitmap(Resource.get("images/23.png"));
  447. var c = p.getBounds();
  448. d.addChild(p);
  449. p.x = (Main.width - c.width) / 2;
  450. p.y = 50;
  451. var m = 0;
  452. var g = 180;
  453. var f = 700;
  454. var l = new createjs.Bitmap(Resource.get("images/13.png"));
  455. var c = l.getBounds();
  456. l.x = (Main.width - c.width) / 2;
  457. l.y = 700;
  458. l.addEventListener("click",
  459. function (r) {
  460. r.preventDefault();
  461. r.stopPropagation();
  462. Main.firstFlag = false;
  463. Main.getGameBeginMsg()
  464. });
  465. d.addChild(l);
  466. m++;
  467. Main.addShareBtn(d, 20, Main.height - 80);
  468. if (gamef.platType == PLAT_BJY || gamef.platType == PLAT_WX) {
  469. var k = new createjs.Bitmap(Resource.get("images/08.png"));
  470. k.x = l.x;
  471. k.y = l.y + 110;
  472. k.cursor = "pointer";
  473. k.addEventListener("click",
  474. function () {
  475. try {
  476. JQMethod.messageBox_show(7)
  477. } catch (r) { }
  478. });
  479. d.addChild(k);
  480. var o = new createjs.Bitmap(Resource.get("images/09.png"));
  481. var c = o.getBounds();
  482. o.x = (Main.width - c.width) / 2;
  483. o.y = k.y + 110;
  484. o.cursor = "pointer";
  485. o.addEventListener("click",
  486. function () {
  487. Main.showHongbao()
  488. });
  489. d.addChild(o)
  490. } else {
  491. var i = new createjs.Bitmap(Resource.get("images/61.png"));
  492. i.x = l.x;
  493. i.y = l.y + 110;
  494. i.cursor = "pointer";
  495. i.addEventListener("click",
  496. function () {
  497. Main.showGonglue()
  498. });
  499. d.addChild(i);
  500. var h = new createjs.Bitmap(Resource.get("images/60.png"));
  501. var c = h.getBounds();
  502. h.x = (Main.width - c.width) / 2;
  503. h.y = i.y + 110;
  504. h.cursor = "pointer";
  505. h.addEventListener("click",
  506. function () {
  507. downLoadZhangDa()
  508. });
  509. d.addChild(h)
  510. }
  511. var j = new createjs.Bitmap(Resource.get("images/37.png"));
  512. j.x = 98;
  513. j.y = 620;
  514. Main.remainCountBg = j;
  515. d.addChild(j);
  516. var q = new createjs.Text("", "20px Arial Black", "#FFffff");
  517. q.x = j.x + 60;
  518. q.y = j.y + 20;
  519. q.text = "你的剩余\n游戏次数还";
  520. q.textAlign = "center";
  521. d.addChild(q);
  522. Main.remainCountTipsTxt = q;
  523. var q = new createjs.Text("", "20px Arial Black", "#FFffff");
  524. q.x = j.x + 20;
  525. q.y = j.y + 70;
  526. q.text = "有0次";
  527. d.addChild(q);
  528. Main.remainCountTxt = q;
  529. var q = new createjs.Text("", "24px Arial Black", "#FFffff");
  530. q.x = 422;
  531. q.y = 942;
  532. q.text = "";
  533. d.addChild(q);
  534. q.textBaseline = "middle";
  535. q.textAlign = "center";
  536. Main.wordCountTxt = q;
  537. Main.showTimes();
  538. d.y = -Main.height;
  539. createjs.Tween.get(d, {
  540. loop: false
  541. }).wait(100).to({
  542. y: 0,
  543. alpha: 1
  544. },
  545. 500, createjs.Ease.quintInOut);
  546. if (Main.bjyFlag) {
  547. gameOverTzCheck(Main.nowScore)
  548. }
  549. var q = new createjs.Text("", " bold 30px Arial Black", "#000000");
  550. q.x = 100;
  551. q.y = 390;
  552. var n = "我家母鸡下了" + Main.nowScore + "个蛋,给你当圣诞\n礼物也是极好的!";
  553. d.addChild(q);
  554. // ih5game.setShare({
  555. // desc: "我家母鸡下了" + Main.nowScore + "个蛋,超过了" + Main.getSharePercent(Main.nowScore) + "%的网友,给你当圣诞礼物也是极好的!"
  556. // });
  557. if (Main.nowScore < 40) {
  558. n += "\n不过弱爆了,全国的小伙伴都把\n你超越了!"
  559. } else {
  560. if (Main.nowScore < 280) {
  561. n += "\n挤蛋能力超过全国" + Main.getSharePercent(Main.nowScore) + "%的网友!"
  562. } else {
  563. n += "\n小伙你下蛋太多了,由于你手速过快,系统运算不出来认为是作弊了!"
  564. }
  565. }
  566. q.text = n
  567. };
  568. Main.showHongbao = function () {
  569. JQMethod.game_Prize();
  570. if (gamef.platType == PLAT_BJY) { }
  571. };
  572. Main.showTimes = function () {
  573. if (Main.remainCountTxt) {
  574. Main.remainCountTxt.text = "有" + Main.remainCount + "次"
  575. }
  576. var b = true;
  577. if (Main.remainCount == null) {
  578. b = false
  579. }
  580. if (Main.remainCountTipsTxt) {
  581. Main.remainCountTipsTxt.visible = b
  582. }
  583. if (Main.remainCountTxt) {
  584. Main.remainCountTxt.visible = b
  585. }
  586. if (Main.remainCountBg) {
  587. Main.remainCountBg.visible = b
  588. }
  589. b = true;
  590. if (Main.wordCount == null) {
  591. b = false
  592. }
  593. if (Main.wordCountTxt) {
  594. Main.wordCountTxt.text = Main.wordCount;
  595. Main.wordCountTxt.visible = b
  596. }
  597. };
  598. Main.loadTime = function () {
  599. if (gamef.platType == PLAT_BJY) {
  600. var b = "webgame/times";
  601. gamef.requestServerData(b, "GET", Main.loadTimeBack, "type=" + gamef.gameid)
  602. } else {
  603. if (gamef.platType == PLAT_WX) {
  604. var b = WXDOMAIN + "wxgame/times";
  605. gamef.requestServerData(b, "GET", Main.loadTimeBack, "type=" + gamef.gameid + "&open_id=" + gamef.open_id)
  606. } else {
  607. Main.remainCount = null;
  608. Main.wordCount = null
  609. }
  610. }
  611. };
  612. Main.loadTimeBack = function (e, c, d) {
  613. var b = d;
  614. if (typeof d === "string") {
  615. b = JSON.parse(d)
  616. }
  617. Main.sendFlag = false;
  618. this.resultCode = b.status;
  619. if (b.status == 0) {
  620. Main.remainCount = b.userBallonInfo.remainCount;
  621. Main.wordCount = b.userBallonInfo.wordCount;
  622. gamef.myKey = b.userBallonInfo.key;
  623. gamef.setLinkUrl();
  624. Main.showTimes()
  625. } else {
  626. toast("无法连接到网络,请检查网络设置后再试")
  627. }
  628. };
  629. Main.addTimes = function () {
  630. if (gamef.key != null) {
  631. if (gamef.platType == PLAT_BJY) {
  632. gamef.requestServerData("webgame/click", "GET", Main.addTimesBack, "key=" + gamef.key)
  633. } else {
  634. if (gamef.platType == PLAT_WX) { }
  635. }
  636. }
  637. };
  638. Main.addTimesBack = function (d, b, c) { };
  639. Main.initStage = function () {
  640. if (!this.stage) {
  641. Main.stage = new createjs.Stage("canvas")
  642. }
  643. if (IS_TOUCH = createjs.Touch.isSupported()) {
  644. createjs.Touch.enable(Main.stage, !0);
  645. Main.stage.mouseEnabled = !1
  646. }
  647. Main.stage.removeAllEventListeners();
  648. Main.stage.removeAllChildren();
  649. Main.stage.removeAllChildren();
  650. Main.stage.removeAllEventListeners();
  651. Main.stage.width = canvas.width = Main.width;
  652. Main.stage.height = canvas.height = Main.height;
  653. Main.checkBJY();
  654. Main.addTimes();
  655. Main.loadTime();
  656. createjs.Ticker.addEventListener("tick", this.stage);
  657. Resource.load();
  658. Resource.queue.addEventListener("complete",
  659. function () {
  660. Main.startGame()
  661. })
  662. };
  663. eventCD = false;
  664. Main.eventHandler = {
  665. stageClick: function (b) {
  666. if (!eventCD) {
  667. eventCD = true;
  668. setTimeout(function () {
  669. eventCD = false
  670. },
  671. 500)
  672. }
  673. }
  674. };
  675. Main.initGame = function () {
  676. if (Main.beginContainer) {
  677. Main.beginContainer.removeAllEventListeners();
  678. Main.beginContainer.removeAllChildren();
  679. Main.beginContainer = null
  680. }
  681. Main.clearGonglue();
  682. Main.gonglueContainer = null;
  683. Main.sendFlag = false;
  684. Main.remainCountTxt = null;
  685. Main.wordCountTxt = null;
  686. Main.initGame = function () { };
  687. var c = new createjs.Bitmap(Resource.get("images/11.jpg"));
  688. Main.stage.addChild(c);
  689. Main.initEvent(c);
  690. createjs.Ticker.addEventListener("tick",
  691. function (l) {
  692. Main.isPlaying && (Main.checkT -= parseInt(l.delta), Main.checkT < 0 && (Main.checkT = 300, t = (new Date).getTime(), t > (Main.gameT + Main.beginT) && (Main.isPlaying = false, setTimeout(Main.sendGameResult, 50)), Main.reset.showTime(t)), Main.checkTouch && Main.wingMovie())
  693. });
  694. Main.initEggs();
  695. var h = new createjs.Bitmap(Resource.get("images/55.png"));
  696. var b = h.getBounds();
  697. h.x = (Main.width - h.getBounds().width) / 2;
  698. h.y = 500;
  699. Main.bear = h;
  700. this.stage.addChild(h);
  701. var g = new createjs.Bitmap(Resource.get("images/33.png"));
  702. b = g.getBounds();
  703. this.bearFight = g;
  704. g.x = (Main.width - h.getBounds().width) / 2;
  705. g.y = 420;
  706. Main.bearFight = g;
  707. this.stage.addChild(g);
  708. var k = new createjs.Bitmap(Resource.get("images/02.png"));
  709. b = k.getBounds();
  710. this.leftWing = k;
  711. k.regX = b.width / 2;
  712. k.regY = b.height * 0.8;
  713. k.rotation = -30;
  714. this.stage.addChild(k);
  715. var f = new createjs.Bitmap(Resource.get("images/02.png"));
  716. this.rightWing = f;
  717. f.regX = b.width / 2;
  718. f.regY = b.height * 0.8;
  719. f.rotation = 30;
  720. this.stage.addChild(f);
  721. var d = new createjs.Container();
  722. d.setBounds(0, 0, 238, 56);
  723. var j = new createjs.Text("", "32px Arial Black", "#FFffff");
  724. j.x = 210;
  725. j.y = 15;
  726. d.addChild(j);
  727. timetext = new createjs.Text("", "40px Arial Black", "#FFffff");
  728. timetext.x = 325;
  729. timetext.y = 50;
  730. d.addChild(timetext);
  731. this.timetext = timetext;
  732. this.scoreText = j;
  733. this.score = d;
  734. this.stage.addChild(d);
  735. this.reset.score();
  736. d = top = j = null;
  737. Main.reset.replay();
  738. if (Main.gameTimes == 0) {
  739. var i = new createjs.Bitmap(Resource.get("images/25.png"));
  740. i.y = 200;
  741. var b = i.getBounds();
  742. i.regX = b.width / 2;
  743. i.x = Main.width / 2;
  744. i.regY = 0;
  745. Main.stage.addChild(i);
  746. var e = new createjs.Bitmap(Resource.get("images/24.png"));
  747. e.x = i.x;
  748. e.y = 200;
  749. Main.stage.addChild(e);
  750. Main.arrow = i;
  751. Main.hand = e;
  752. Main.guildMovie()
  753. }
  754. JQMethod.bg_color_orange()
  755. };
  756. Main.guildMovie = function () {
  757. if (Main.arrow) {
  758. createjs.Tween.get(Main.arrow).to({
  759. y: Main.height,
  760. scaleX: 1.5,
  761. scaleY: 1.5
  762. },
  763. 0).to({
  764. alpha: 0.4,
  765. y: 100,
  766. scaleX: 1,
  767. scaleY: 1
  768. },
  769. 1500).wait(300).call(Main.guildMovie)
  770. }
  771. if (Main.hand) {
  772. createjs.Tween.get(Main.hand).to({
  773. y: Main.height
  774. },
  775. 0).to({
  776. y: -200
  777. },
  778. 1700)
  779. }
  780. };
  781. Main.clearHandMovie = function () {
  782. if (Main.arrow) {
  783. createjs.Tween.removeTweens(Main.arrow);
  784. createjs.Tween.removeTweens(Main.hand);
  785. Main.stage.removeChild(Main.arrow);
  786. Main.stage.removeChild(Main.hand);
  787. Main.hand = null;
  788. Main.arrow = null;
  789. Main.gameTimes += 1;
  790. try {
  791. localStorage["gameTimes"] = Main.gameTimes
  792. } catch (b) { }
  793. }
  794. };
  795. Main.initEvent = function (e) {
  796. var d = 0,
  797. c = 0,
  798. b = 0;
  799. e.on("mousedown",
  800. function (f) {
  801. Main.isPlaying && (d = f.localY)
  802. });
  803. e.on("pressmove",
  804. function (f) {
  805. Main.isPlaying && Main.prepareFight()
  806. });
  807. e.on("pressup",
  808. function (f) {
  809. Main.isPlaying && Main.showHenFight(100) && 50 < d - f.localY && (c = (new Date).getTime(), 50 + b < c && (Main.addSocre(1), Main.ShowEggFly(), Main.clearHandMovie()), b = c)
  810. })
  811. };
  812. Main.wingMovie = function () {
  813. rightWing = Main.rightWing,
  814. leftWing = Main.leftWing,
  815. rightWing.rotation += Main.RightWingRFlag;
  816. rightWing.rotation < 15 && (Main.RightWingRFlag = Main.rotationStep, rightWing.rotation = 15) || rightWing.rotation > 30 && (Main.RightWingRFlag = -Main.rotationStep, rightWing.rotation = 30);
  817. leftWing.rotation = rightWing.rotation * -1
  818. };
  819. Main.prepareFight = function () {
  820. if (Main.checkTouch == false) {
  821. Main.bear.visible = !1,
  822. Main.bearFight.visible = !0;
  823. var c = Main.rightWing;
  824. var b = Main.leftWing;
  825. c.y = b.y = 820,
  826. b.x = 140,
  827. Main.checkTouch = true
  828. }
  829. };
  830. Main.showHenFight = function (b) {
  831. createjs.Tween.removeTweens(Main.bearFight);
  832. createjs.Tween.get(Main.bearFight).wait(b).call(Main.resetHen);
  833. return true
  834. };
  835. Main.resetHen = function () {
  836. Main.bear.visible = !0;
  837. Main.bearFight.visible = !1;
  838. var c = Main.rightWing;
  839. var b = Main.leftWing;
  840. c.x = 490;
  841. b.x = 150;
  842. c.y = b.y = 870;
  843. c.rotation = b.rotation = 0;
  844. Main.checkTouch = false
  845. };
  846. Main.ShowEggFly = function () {
  847. a = Main.eggArr[Main.eggIndex];
  848. a.visible = !0;
  849. createjs.Tween.get(a).to({
  850. y: 100,
  851. scaleX: 0.4,
  852. scaleY: 0.4
  853. },
  854. 300).to({
  855. visible: !1,
  856. y: 550,
  857. scaleX: 1,
  858. scaleY: 1
  859. },
  860. 0);
  861. 0 < Main.eggIndex ? Main.eggIndex-- : Main.eggIndex = Main.eggMax - 1
  862. };
  863. Main.initEggs = function () {
  864. for (var b = 0; b < Main.eggMax; b++) {
  865. var c = new createjs.Bitmap(Resource.get("images/04.png"));
  866. c.regX = 50;
  867. c.regY = 68;
  868. c.x = 315;
  869. c.y = 550;
  870. Main.eggArr[b] = c;
  871. Main.stage.addChild(c);
  872. c.visible = !1
  873. }
  874. };
  875. Main.addSocre = function (b) {
  876. Main.nowScore += b;
  877. Main.reset.score(Main.nowScore)
  878. };
  879. Main.penguinOffsetX = 325;
  880. Main.reset = {
  881. replay: function () {
  882. this.score();
  883. Main.isPlaying = true;
  884. Main.isQuiver = false;
  885. Main.beginT = (new Date).getTime();
  886. Main.guideMoveLength = 0;
  887. Main.guideMoveIndex = 1;
  888. Main.nowScore = 0;
  889. this.showTime();
  890. Main.checkT = 200;
  891. Main.resetHen()
  892. },
  893. score: function (b) {
  894. var c = Main.scoreText;
  895. c.text = "得分:" + (b || 0)
  896. },
  897. showTime: function (d) {
  898. var b = d || (new Date).getTime();
  899. var c = Main.timetext;
  900. b = Math.ceil((Main.beginT + Main.gameT - b) / 1000);
  901. b > 0 ? c.text = b : c.text = 0
  902. }
  903. };
  904. Main.isPlaying = false;
  905. Main.isQuiver = false;
  906. Main.sendGameResult = function () {
  907. Main.log("---------sendGameResult");
  908. if (Main.sendOverFlag == true) {
  909. return
  910. }
  911. Main.sendOverFlag = 1;
  912. Main.resultCode = -1;
  913. Main.countNum += 1;
  914. Main.sendOverFlag = true;
  915. Main.resetHen();
  916. var c = new Object();
  917. c.score = Main.nowScore;
  918. c.maxScore = Main.maxScore;
  919. // ih5game.setShare({
  920. // desc: "我家母鸡下了" + Main.nowScore + "个蛋,给你当圣诞礼物也是极好的!"
  921. // });
  922. c.error_count = 0;
  923. var b = null;
  924. if (gamef.platType == PLAT_BJY) {
  925. b = "webgame/" + Main.user_balloon_id + "/end"
  926. } else {
  927. if (gamef.platType == PLAT_WX) {
  928. b = WXDOMAIN + "wxgame/" + Main.user_balloon_id + "/end"
  929. }
  930. }
  931. gamef.end(b, "GET", Main.sendGameResultBack, c)
  932. };
  933. Main.sendGameResultBack = function (f, c, d) {
  934. var e = Main;
  935. var b = d;
  936. if (typeof d === "string") {
  937. b = JSON.parse(d)
  938. }
  939. e.sendOverFlag = false;
  940. e.resultCode = b.status;
  941. if (b.status == 0) {
  942. Main.nowScore = b.userBallonInfo.now_count;
  943. Main.maxScore = b.userBallonInfo.max_count;
  944. Main.remainCount = b.userBallonInfo.remainCount;
  945. Main.wordCount = b.userBallonInfo.wordCount;
  946. gamef.myKey = b.userBallonInfo.key;
  947. Main.rewardId = b.userBallonInfo.rewardId;
  948. gamef.setLinkUrl();
  949. setTimeout(function () {
  950. Main.endGame(Main.nowScore)
  951. },
  952. 100)
  953. } else {
  954. if (b.status == 2) {
  955. toast("游戏不存在")
  956. } else {
  957. if (b.status == 2017) {
  958. toast("用户不存在")
  959. } else {
  960. toast("无法连接到网络,请检查网络设置后再试")
  961. }
  962. }
  963. setTimeout(function () {
  964. Main.endGame(Main.nowScore)
  965. },
  966. 100)
  967. }
  968. };
  969. btGame.resizePlayArea($("#container"), Main.width, Main.height, "center", "center");