app.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. function isAndroid() {
  2. return /Android/i.test(navigator.userAgent)
  3. }
  4. var atype = "",
  5. atype = isAndroid() ? ".ogg" : ".mp3",
  6. res = {
  7. role_plist: "res/roles.plist",
  8. role_png: "res/roles.png",
  9. light_plist: "res/light.plist",
  10. light_png: "res/light.png",
  11. blood_plist: "res/blood.plist",
  12. blood_png: "res/blood.png",
  13. game_png: "res/games.png",
  14. game_plist: "res/games.plist",
  15. num_png: "res/num50.png",
  16. bg: "res/gamebg.png",
  17. shareword: "res/shareword.png"
  18. },
  19. g_mainmenu = [res.game_plist, res.game_png, res.role_png, res.role_plist, res.light_png, res.light_plist, res.blood_png, res.blood_plist, res.num_png, res.bg, res.shareword];
  20. var GD = GD || {};
  21. GD.GAME_STATE = {
  22. HOME: 0,
  23. PLAY: 1,
  24. OVER: 2
  25. };
  26. GD.UNIT_TAG = {
  27. ENEMY: 100,
  28. PLAYER: 1E3,
  29. PET: 1010,
  30. BLOOD: 1020
  31. };
  32. GD.ACTIVE_PETS = 0;
  33. GD.ACTIVE_ENEMIES = 0;
  34. GD.CONTAINER = {
  35. ENEMIES: [],
  36. BLOOD: [],
  37. LIGHT: [],
  38. LIGHT2: [],
  39. BACKSKYS: [],
  40. HitMo: [],
  41. PET: [],
  42. BACKTILEMAPS: []
  43. };
  44. GD.ENEMIES = {};
  45. GD.ENEMIES.DATA = [{
  46. power: 0.6,
  47. live: 1,
  48. speed: 4,
  49. fimg: "npc1",
  50. bimg: "npc2"
  51. }, {
  52. power: 1,
  53. live: 1,
  54. speed: 4,
  55. fimg: "npc3",
  56. bimg: "npc4"
  57. }];
  58. GD.LIFE = 10;
  59. GD.PETKIND = 0;
  60. GD.SHOWLEVEL = 0;
  61. GD.SCORE = 0;
  62. var winSize, centerPos;
  63. GD.word = ["0", "1"];
  64. var BitNumLayer = cc.Layer.extend({
  65. timeLabel: null,
  66. scoreLabel: null,
  67. time: null,
  68. timeAction: null,
  69. _bg: null,
  70. ctor: function() {
  71. this._super()
  72. },
  73. step: function(a) {
  74. this.time += a
  75. },
  76. init: function() {
  77. this._super();
  78. this.scoreLabel = cc.LabelAtlas.create("0", res.num_png, 65, 87, "0");
  79. this.addChild(this.scoreLabel);
  80. this.scoreLabel.anchorX = 0.5;
  81. this.scoreLabel.x = winSize.width / 2;
  82. this.scoreLabel.y = -120 + winSize.height;
  83. var a = cc.ScaleBy.create(0.1, 1.2);
  84. this.scoreLabel.scale = 0.8;
  85. cc.ScaleBy.create(2, 0.25, 4.5);
  86. this.timeAction = cc.Sequence.create(a,
  87. a.reverse());
  88. this.schedule(this.step);
  89. this.setTimeNum(0)
  90. },
  91. setNum: function(a) {
  92. GD.SCORE += a;
  93. trace("--------SCORE---" + GD.SCORE);
  94. this.scoreLabel.scale = 0.8;
  95. this.scoreLabel.runAction(this.timeAction);
  96. this.scoreLabel.setString(GD.SCORE + "")
  97. },
  98. setTimeNum: function(a) {}
  99. });
  100. BitNumLayer.create = function() {
  101. var a = new BitNumLayer;
  102. a.init();
  103. return a
  104. };
  105. var Fire = cc.Layer.extend({
  106. _tao: null,
  107. _live: 3,
  108. _action: null,
  109. _hp: null,
  110. _barRenderer: null,
  111. _barsize: null,
  112. barbg: null,
  113. ctor: function(a) {
  114. this._super()
  115. },
  116. setLive: function(a) {
  117. 0 != this._live && (this._live -= a, 0 >= this._live && (this._live = 0, this.toEnd()), a = 100 * (this._live / GD.LIFE) | 0, a = Math.min(a, 100), this._barRenderer && this._barRenderer.setTextureRect(cc.rect(0, 0, 95 * a / 100, 10)))
  118. },
  119. step: function(a) {
  120. this.time += a
  121. },
  122. init: function() {
  123. this._super();
  124. this._barRenderer = new cc.Sprite.create("#bar.png");
  125. this._barsize = [this._barRenderer.width,
  126. this._barRenderer.height
  127. ];
  128. this._live = GD.LIFE;
  129. var a = new cc.Sprite.create("#bar.png");
  130. a.color = cc.color(25, 25, 25, 150);
  131. a.anchorX = this._barRenderer.anchorX = 0;
  132. a.anchorY = this._barRenderer.anchorY = 0;
  133. a.x = this._barRenderer.x = -50;
  134. a.y = this._barRenderer.y = 160;
  135. a.y -= 3;
  136. this.addChild(a);
  137. this.barbg = a;
  138. this._barRenderer.color = cc.color.RED;
  139. this.addChild(this._barRenderer);
  140. this._tao = new cc.Sprite.create("#ta0001.png");
  141. this._tao.anchorY = 0.3;
  142. this._tao.anchorX = 0.55;
  143. this.addChild(this._tao);
  144. for (var a = [], b = 1; 12 >= b; b++) {
  145. var c =
  146. cc.spriteFrameCache.getSpriteFrame("ta00" + (9 < b ? b : "0" + b) + ".png");
  147. a.push(c)
  148. }
  149. this._action = cc.Sequence.create(cc.Animate.create(cc.Animation.create(a, 0.06)), cc.CallFunc.create(this.gameOver, this));
  150. this.setLive(0)
  151. },
  152. toEnd: function() {
  153. this.barbg.visible = !1;
  154. this._tao.runAction(this._action);
  155. g_sharedGameLayer.loseGame()
  156. },
  157. gameOver: function() {}
  158. });
  159. Fire.create = function() {
  160. var a = new Fire;
  161. a.init();
  162. return a
  163. };
  164. var Helo = cc.Sprite.extend({
  165. eID: 0,
  166. active: !0,
  167. direct: 1,
  168. hurtAction: null,
  169. standAction: null,
  170. hasFired: !1,
  171. attactKind: 0,
  172. lock: !1,
  173. ax: 0,
  174. ay: 0,
  175. ox: 0,
  176. oy: 0,
  177. apot: null,
  178. addpot: null,
  179. speednum: 20,
  180. speedp: null,
  181. nextaim: null,
  182. isOpen: !1,
  183. roadlist: [],
  184. _draw: null,
  185. circle: 140,
  186. _linep: null,
  187. ctor: function() {
  188. this._super("#role0001.png");
  189. this.install();
  190. this.anchorY = this.anchorX = 0.5;
  191. this.runAction(this.frameObj.round);
  192. this.isOpen = !0;
  193. this.scale = 1.1
  194. },
  195. install: function() {
  196. this.apot = this.getPosition();
  197. this.attactActionList = [];
  198. var a = [
  199. [
  200. [2, 9], "round"
  201. ],
  202. [
  203. [10, 42], "die"
  204. ]
  205. ],
  206. b;
  207. this.frameObj = {};
  208. for (var c = [], e, d = 0; d < a.length; d++)
  209. for (var c = [], f = a[d][0], g = f[0]; g < f[1]; g++) b = g, b = 10 > b ? "00" + b : 100 > b ? "0" + b : b, str = "role0" + b + ".png", b = cc.spriteFrameCache.getSpriteFrame(str), c.push(b), b = a[d][1], "round" == b ? e = cc.RepeatForever.create(cc.Animate.create(cc.Animation.create(c, 0.025))) : "die" == b && (e = cc.Sequence.create(cc.Animate.create(cc.Animation.create(c, 0.05)), cc.CallFunc.create(this.destroy, this))), e.retain(), this.frameObj[a[d][1]] = e
  210. },
  211. setDirect: function(a) {
  212. this.scaleX =
  213. this.direct = a
  214. },
  215. setNewPot: function(a) {
  216. a.x == this.apot.x && a.y == this.apot.y || (this.apot = a, this.findRoad())
  217. },
  218. update: function(a) {
  219. this.nextaim && (cc.pDistance(this.nextaim, this.getPosition()) > this.speednum ? (a = cc.pAdd(this.getPosition(), this.speedp), this.setPosition(a)) : (this.setPosition(this.nextaim), this.roadlist.shift(), this.refreshNext()), this.scale = (1E3 - this.y) / 1E3 + 0.7, this.scale = 1.2 < this.scale ? 1.2 : this.scale)
  220. },
  221. refreshNext: function() {
  222. 1 < this.roadlist.length ? (this.nextaim = this.roadlist[1], this.speedp = cc.pMult(cc.pNormalize(cc.pSub(this.nextaim,
  223. this.getPosition())), this.speednum), this.drawdot(this.roadlist)) : (this._draw.clear(), this.nextaim = null)
  224. },
  225. findRoad: function() {
  226. this.roadlist = [];
  227. this.roadlist.push(this.getPosition());
  228. cc.pDistance(this.getPosition(), this.apot);
  229. var a = cc.pDistance(centerPos, this.getPosition());
  230. this._linep = cc.pSub(this.apot, this.getPosition());
  231. var b = cc.pSub(centerPos, this.getPosition()),
  232. c = cc.pNormalize(this._linep),
  233. e = cc.pAngle(b, this._linep),
  234. d = Math.floor(a * Math.sin(e)),
  235. a = Math.floor(a * Math.cos(e));
  236. cc.pDistance(centerPos,
  237. this.apot) < this.circle ? (b = Math.sqrt(this.circle * this.circle - d * d), cc.pSub(centerPos, this._linep), this.apot = cc.pAdd(this.getPosition(), cc.pMult(c, a - b))) : (e = 180 * cc.pAngle(cc.pSub(this.apot, centerPos), cc.pSub(this.getPosition(), centerPos)) / Math.PI, d < this.circle && 90 < e && (c = cc.pSub(cc.pMult(c, a), b), c = cc.pAdd(centerPos, cc.pMult(cc.pNormalize(c), this.circle)), this.roadlist.push(c)));
  238. this.roadlist.push(this.apot);
  239. c = [];
  240. for (b = 0; b < this.roadlist.length - 1; b++)
  241. if (d = cc.pDistance(this.roadlist[b + 1], this.roadlist[b]),
  242. 25 < d) {
  243. d = Math.floor(d / 25);
  244. a = cc.pNormalize(cc.pSub(this.roadlist[b + 1], this.roadlist[b]));
  245. for (e = 0; e <= d; e++) {
  246. var f = cc.pAdd(this.roadlist[b], cc.pMult(a, 25 * e));
  247. c.push(f)
  248. }
  249. } else c.push(this.roadlist[b]);
  250. this.roadlist = c;
  251. this.drawdot(this.roadlist);
  252. this.refreshNext()
  253. },
  254. drawdot: function(a) {
  255. this._draw || (this._draw = cc.DrawNode.create(), g_sharedGameLayer.addRoad(this._draw));
  256. this._draw.clear();
  257. for (var b = 0; b < a.length - 1; b++) this._draw.drawDot(a[b], 5, cc.color(0, 255, 255, 50))
  258. },
  259. destroy: function() {
  260. this.scheduleOnce(this.callBackOver,
  261. 0.5);
  262. this.attactActionList = [];
  263. this.stopAllActions()
  264. },
  265. callBackOver: function() {
  266. g_sharedGameLayer.onGameOver()
  267. },
  268. attactRect: function() {
  269. return cc.rect(this.x, this.y, 100, 100)
  270. },
  271. toDie: function() {
  272. this.stopAllActions();
  273. this.runAction(this.frameObj.die)
  274. }
  275. });
  276. Helo.create = function() {
  277. return new Helo
  278. };
  279. var BgLayer = cc.Layer.extend({
  280. _bgs: null,
  281. _start: null,
  282. _bglist: [],
  283. _bgfshow: [],
  284. _bgbshow: [],
  285. _lefttx: -350,
  286. _fid: 0,
  287. _imgw: 853,
  288. _bid: 0,
  289. ctor: function() {
  290. this._super()
  291. },
  292. step: function(a) {
  293. this.time += a
  294. },
  295. init: function() {
  296. this._super();
  297. this._lefttx = -this._imgw / 2;
  298. this._bgs = cc.Node.create();
  299. this.addChild(this._bgs);
  300. for (var a = [res.bg_png, res.bg_png], b = 0; 2 > b; b++) {
  301. var c = cc.Sprite.create(a[b]);
  302. c.anchorY = 0;
  303. this._bgs.addChild(c);
  304. c.visible = !0;
  305. c.y = 0;
  306. this._bglist.push(c)
  307. }
  308. this._bgfshow.push(this._bglist[0]);
  309. this._bgfshow.push(this._bglist[1]);
  310. this._bgfshow[1].x = this._bgfshow[0].x + this._imgw;
  311. this._fid = 1;
  312. for (b = 0; 1 >= b; b++) this._bgfshow[b].visible = !0
  313. },
  314. update: function(a, b) {
  315. for (var c = 0; 2 > c; c++) this._bgfshow[c].x += a;
  316. this._bgfshow[0].x < this._lefttx && (c = this._bgfshow.shift(), c.visible = !1, this._fid += 1, this._bgfshow.push(c), this._bgfshow[1].x = this._bgfshow[0].x + this._imgw, this._bgfshow[1].visible = !0)
  317. },
  318. setIndex: function(a, b) {}
  319. });
  320. BgLayer.create = function() {
  321. var a = new BgLayer;
  322. a.init();
  323. return a
  324. };
  325. var Light2 = cc.Sprite.extend({
  326. active: !1,
  327. ctor: function() {
  328. this._super("#l20001.png")
  329. },
  330. destroy: function() {
  331. this.active = this.visible = !1
  332. },
  333. init: function() {
  334. this._super()
  335. },
  336. playMo: function() {
  337. this.scale = 1.3;
  338. this.active = this.visible = !0;
  339. this.runAction(cc.Sequence.create(cc.Animate.create(cc.animationCache.getAnimation("l22")), cc.CallFunc.create(this.destroy, this)))
  340. }
  341. });
  342. Light2.addNew = function(a) {
  343. Light2.getOrCreate(a).playMo()
  344. };
  345. Light2.getOrCreate = function(a) {
  346. for (var b = null, c = 0; c < GD.CONTAINER.LIGHT2.length; c++)
  347. if (b = GD.CONTAINER.LIGHT2[c], !1 == b.active) return b.setPosition(a), b;
  348. b = Light2.create();
  349. b.setPosition(a);
  350. return b
  351. };
  352. Light2.shared = function() {
  353. for (var a = [], b = 1; 7 >= b; b++) {
  354. var c = cc.spriteFrameCache.getSpriteFrame("l2000" + b + ".png");
  355. a.push(c)
  356. }
  357. cc.animationCache.addAnimation(cc.Animation.create(a, 0.02), "l22")
  358. };
  359. Light2.create = function(a) {
  360. a = new Light2(a);
  361. g_sharedGameLayer.addLight2(a);
  362. GD.CONTAINER.LIGHT2.push(a);
  363. return a
  364. };
  365. var Blood = cc.Sprite.extend({
  366. active: !1,
  367. ctor: function() {
  368. this._super("#blood0001.png");
  369. this.anchorX = 0;
  370. this.anchorY = 0.5
  371. },
  372. destroy: function() {
  373. this.active = this.visible = !1
  374. },
  375. init: function() {
  376. this._super()
  377. },
  378. playMo: function() {
  379. this.active = this.visible = !0;
  380. this.runAction(cc.Sequence.create(cc.Animate.create(cc.animationCache.getAnimation("Blood")), cc.CallFunc.create(this.destroy, this)))
  381. }
  382. });
  383. Blood.addNew = function(a, b) {
  384. var c = Blood.getOrCreate();
  385. c.setPosition(a);
  386. c.rotation = 360 - b;
  387. c.playMo()
  388. };
  389. Blood.getOrCreate = function() {
  390. for (var a = null, b = 0; b < GD.CONTAINER.BLOOD.length; b++)
  391. if (a = GD.CONTAINER.BLOOD[b], !1 == a.active) return a;
  392. return a = Blood.create()
  393. };
  394. Blood.shared = function() {
  395. for (var a = [], b = 2; 9 >= b; b++) {
  396. var c = cc.spriteFrameCache.getSpriteFrame("blood000" + b + ".png");
  397. a.push(c)
  398. }
  399. cc.animationCache.addAnimation(cc.Animation.create(a, 0.1), "Blood")
  400. };
  401. Blood.create = function(a) {
  402. a = new Blood(a);
  403. g_sharedGameLayer.addBlood(a);
  404. GD.CONTAINER.BLOOD.push(a);
  405. return a
  406. };
  407. var Enemy = cc.Sprite.extend({
  408. aimX: 0,
  409. speedx: 5,
  410. speedy: 0,
  411. rightsidex: 0,
  412. leftsidex: 0,
  413. showLevel: 0,
  414. hasFired: !1,
  415. race: 1,
  416. kind: 1,
  417. power: 1,
  418. liveAction: null,
  419. dieAction: null,
  420. attactSpace: 6,
  421. attactAction: null,
  422. speednum: 1,
  423. state: "no",
  424. dirx: 1,
  425. diry: 1,
  426. live: 1,
  427. angle: null,
  428. speedp: null,
  429. orip: null,
  430. race: null,
  431. attactLen: 150,
  432. oripot: null,
  433. angle: null,
  434. money: null,
  435. ctor: function(a, b) {
  436. this.diry = 2 < b ? 1 : -1;
  437. 1 == this.diry && (this.attactLen = 160);
  438. this.dirx = 1 == b % 2 ? 1 : -1;
  439. this.race = a; - 1 == this.diry ? this._super("#" + GD.ENEMIES.DATA[a].fimg + "0001.png") : this._super("#" +
  440. GD.ENEMIES.DATA[a].bimg + "0001.png");
  441. 1 == a ? (this.attactLen += 10, this.money = 40) : 1 == this.diry ? (this.money = 19, this.attactLen -= 30) : (this.money = 16, this.attactLen -= 10);
  442. this.kind = b;
  443. this.anchorY = this.anchorX = 0.5;
  444. this.rightsidex = winSize.width;
  445. this.power = GD.ENEMIES.DATA[a].power;
  446. this.speednum = GD.ENEMIES.DATA[a].speed;
  447. this.live = GD.ENEMIES.DATA[a].live;
  448. for (var c = [], e = [], d = 1; 6 >= d; d++) {
  449. var f = cc.spriteFrameCache.getSpriteFrame(-1 == this.diry ? "" + GD.ENEMIES.DATA[a].fimg + "000" + d + ".png" : "" + GD.ENEMIES.DATA[a].bimg + "000" +
  450. d + ".png");
  451. 3 >= d ? c.push(f) : e.push(f)
  452. }
  453. this.liveAction = cc.RepeatForever.create(cc.Animate.create(cc.Animation.create(c, 0.1)));
  454. this.attactAction = cc.Sequence.create(cc.Animate.create(cc.Animation.create(e, 0.1)), cc.CallFunc.create(this.attactEnd, this));
  455. this.scaleX = this.dirx
  456. },
  457. toGetNewPot: function() {
  458. this.angle = 8 * (6 * Math.random() - 3) + [135, 45, 225, 315][this.kind - 1];
  459. for (var a = 0; a < GD.CONTAINER.ENEMIES.length; a++) {
  460. var b = GD.CONTAINER.ENEMIES[a];
  461. if ("run" == b.state && this.angle == b.angle) {
  462. this.toGetNewPot();
  463. return
  464. }
  465. }
  466. a =
  467. cc.pForAngle(this.angle / 360 * 2 * Math.PI);
  468. b = cc.pMult(a, 500);
  469. this.orip = a;
  470. this.oripot = cc.pAdd(centerPos, b);
  471. this.speedp = cc.pNeg(cc.pMult(a, this.speednum))
  472. },
  473. toActive: function(a) {
  474. this.speednum = a + GD.ENEMIES.DATA[this.race].speed;
  475. this.toGetNewPot();
  476. this.dieAction = cc.Sequence.create(cc.MoveTo.create(0.1, this.oripot), cc.CallFunc.create(this.destroy, this));
  477. this.setPosition(this.oripot);
  478. this.visible = !0;
  479. this.alpha = 1;
  480. this.toRun()
  481. },
  482. update: function(a) {
  483. "run" == this.state && (cc.pDistance(centerPos, this.getPosition()) >
  484. this.attactLen ? (a = cc.pAdd(this.getPosition(), this.speedp), this.setPosition(a)) : this.toAttact())
  485. },
  486. toAttact: function() {
  487. "run" != this.state && "attact" != this.state || (this.state = "attact", this.stopAllActions(), this.runAction(this.attactAction))
  488. },
  489. attactEnd: function() {
  490. this.scheduleOnce(this.toAttact, 1);
  491. g_sharedGameLayer.enemyAttact(this.power, this.orip)
  492. },
  493. toRun: function() {
  494. this.state = "run";
  495. this.stopAllActions();
  496. this.runAction(this.liveAction)
  497. },
  498. toBeHurt: function(a, b) {
  499. this.state = "hurt";
  500. this.kill(b)
  501. },
  502. kill: function(a) {
  503. this.state =
  504. "die";
  505. this.stopAllActions();
  506. this.runAction(this.dieAction);
  507. g_sharedGameLayer.killOneEnemy(this)
  508. },
  509. destroy: function() {
  510. this.active = this.visible = !1;
  511. GD.ACTIVE_ENEMIES--;
  512. this.stopAllActions();
  513. g_sharedGameLayer.oneEnemyDie(this)
  514. },
  515. gameOver: function() {},
  516. attactRect: function() {
  517. return cc.rect(this.x, -1, 60, -1)
  518. },
  519. collideRect: function(a, b) {
  520. return cc.rect(this.x, -1, 50, -1)
  521. }
  522. });
  523. Enemy.addNewEnemy = function(a, b) {
  524. if (!(20 <= GD.ACTIVE_ENEMIES)) {
  525. GD.SHOWLEVEL += 1;
  526. var c = 0.7 < Math.random() ? 1 : 0;
  527. Enemy.getOrCreateEnemy(c, a).toActive(b)
  528. }
  529. };
  530. Enemy.getOrCreateEnemy = function(a, b) {
  531. for (var c = null, e = 0; e < GD.CONTAINER.ENEMIES.length; e++)
  532. if (c = GD.CONTAINER.ENEMIES[e], c.race == a && c.kind == b && "no" == c.state) return GD.ACTIVE_ENEMIES++, c;
  533. c = Enemy.create(a, b);
  534. GD.ACTIVE_ENEMIES++;
  535. return c
  536. };
  537. Enemy.create = function(a, b) {
  538. var c = new Enemy(a, b);
  539. g_sharedGameLayer.addEnemy(c, GD.UNIT_TAG.ENEMY, c.zOrder);
  540. GD.CONTAINER.ENEMIES.push(c);
  541. return c
  542. };
  543. Enemy.preSet = function() {
  544. for (var a = null, a = 1, b, c = 0; 8 > c; c++) a = 3 < c ? 1 : 0, b = c % 4, a = Enemy.create(a, b + 1), a.visible = !1, a.state = "no", a.stopAllActions(), a.unscheduleAllCallbacks()
  545. };
  546. function ShakeCls() {
  547. this.shakeee = null;
  548. var a = this;
  549. this.bool = !1;
  550. this.hitAndShake = function(a, c, e, d, f) {
  551. this.bool = !0;
  552. this.shakeee = a;
  553. null == this.shakeee.basex && (this.shakeee.basex = this.shakeee.x);
  554. null == this.shakeee.basey && (this.shakeee.basey = this.shakeee.y);
  555. this.shakeee.rangeX = null == c ? 20 : c;
  556. this.shakeee.rangeY = null == e ? 20 : e;
  557. this.shakeee.x = this.shakeee.basex - this.shakeee.rangeX / 2 + this.shakeee.rangeX * Math.random();
  558. this.shakeee.y = this.shakeee.basey - this.shakeee.rangeY + 2 * this.shakeee.rangeY * Math.random();
  559. this.shakeee.flashTime =
  560. 6;
  561. this.shakeee.funcCall = null == f ? null : f;
  562. this.shakeee.shakeTimeCount = 0;
  563. this.shakeee.cframe = 0
  564. };
  565. this.update = function() {
  566. this.bool && (this.shakeee.cframe += 1, 2 > this.shakeee.cframe || (this.shakeee.cframe = 0, 5 == this.shakeee.shakeTimeCount ? a.cancelHitAndShake(this.shakeee) : (this.shakeee.shakeTimeCount++, this.shakeee.x += 1.7 * (this.shakeee.basex - this.shakeee.x), this.shakeee.y += 1.7 * (this.shakeee.basey - this.shakeee.y))))
  567. };
  568. this.cancelHitAndShake = function(a) {
  569. this.bool = !1;
  570. a || (a = this.shakeee);
  571. a.x = a.basex;
  572. a.y = a.basey
  573. }
  574. }
  575. var shake = new ShakeCls;
  576. var MenuLayer = cc.Layer.extend({
  577. menu: null,
  578. ctor: function() {
  579. this._super()
  580. },
  581. init: function() {
  582. this._super();
  583. cc.spriteFrameCache.addSpriteFrames(res.game_plist);
  584. centerPos = cc.p(winSize.width / 2, winSize.height / 2);
  585. var a = cc.Sprite.create("#gameintro.png");
  586. this.addChild(a);
  587. this.menu = cc.Sprite.create("#start.png");
  588. this.menu.x = winSize.width / 2;
  589. this.addChild(this.menu);
  590. a.y = winSize.height / 2 + 351.5 - 274;
  591. this.menu.y = a.y - 351.5;
  592. a.x = winSize.width / 2;
  593. this.initEvent();
  594. a = cc.Sprite.create(cc.tglogotexture2d);
  595. a.y = 50;
  596. a.anchorX =
  597. 0.5;
  598. a.x = winSize.width / 2;
  599. this.addChild(a)
  600. },
  601. initEvent: function() {
  602. var a = this,
  603. b = cc.EventListener.create({
  604. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  605. swallowTouches: !1,
  606. onTouchBegan: function(b, e) {
  607. var d = e.getCurrentTarget(),
  608. f = d.convertToNodeSpace(b.getLocation()),
  609. d = d.getContentSize(),
  610. d = cc.rect(0, 0, d.width, d.height);
  611. return cc.rectContainsPoint(d, f) ? (a.menu.y -= 3, a.menu.color = cc.color(150, 150, 150, 150), a.onPlayG(), !0) : !1
  612. },
  613. onTouchEnded: function(a, b) {
  614. return !1
  615. }
  616. });
  617. cc.eventManager.addListener(b, a.menu)
  618. },
  619. onPlayG: function() {
  620. // pgvSendClick &&
  621. // "function" == typeof pgvSendClick && pgvSendClick({
  622. // hottag: "h5game.zgl.start"
  623. // });
  624. cc.director.runScene(cc.TransitionFade.create(0.3, GameScene.create()))
  625. }
  626. }),
  627. MenuScene = cc.Scene.extend({
  628. onEnter: function() {
  629. this._super();
  630. var a = new MenuLayer;
  631. a.init();
  632. this.addChild(a)
  633. }
  634. });
  635. MenuScene.create = function() {
  636. var a = new MenuScene;
  637. return a && a.init() ? a : null
  638. };
  639. STATE_PLAYING = 0;
  640. STATE_GAMEOVER = 1;
  641. var g_sharedGameLayer, GameLayer = cc.Layer.extend({
  642. _size: 0,
  643. _helo: null,
  644. _roles: null,
  645. _time: GD.MAXTIME,
  646. _midx: 0,
  647. _leftmidx: 0,
  648. _rightmidx: 0,
  649. _attactzone: [],
  650. _npcontainer: null,
  651. _introscene: null,
  652. _live: 0,
  653. _blood: null,
  654. _attackLeft: null,
  655. _attackRight: null,
  656. _dataLayer: null,
  657. _state: STATE_PLAYING,
  658. _hitUI: null,
  659. numLayer: null,
  660. _hitNum: 0,
  661. _liveBar: null,
  662. _barRenderer: null,
  663. _time2: 0,
  664. _others: null,
  665. _BtnColor: null,
  666. _space: 60,
  667. _barsize: [168, 17],
  668. _locktime: 3,
  669. _ta: null,
  670. emyspd: 0,
  671. moved: !0,
  672. ctor: function() {
  673. this._super()
  674. },
  675. init: function() {
  676. this._super() &&
  677. (this._space = 0, GD.SCORE = 0, this._time = GD.MAXTIME, GD.CONTAINER.ENEMIES = [], GD.CONTAINER.BLOOD = [], GD.CONTAINER.PET = [], GD.ACTIVE_PETS = 0, GD.ACTIVE_ENEMIES = 0, this._midx = winSize.width / 2, this._leftmidx = this._midx / 2 - 120, this._rightmidx = this._midx + 120, g_sharedGameLayer = this, this.initBg(), this.initRoles(), this.initUserControl(), this.initData(), this._state = STATE_PLAYING, this.schedule(this.clockCounter2, 0.1), this.scheduleUpdate())
  678. },
  679. initRoles: function() {
  680. cc.spriteFrameCache.addSpriteFrames(res.role_plist);
  681. cc.spriteFrameCache.addSpriteFrames(res.light_plist);
  682. cc.spriteFrameCache.addSpriteFrames(res.blood_plist);
  683. var a = cc.textureCache.addImage(res.role_png);
  684. this._roles = cc.SpriteBatchNode.create(a);
  685. this._roles.setBlendFunc(cc.SRC_ALPHA, cc.ONE);
  686. this._ta = Fire.create();
  687. this._ta.x = winSize.width / 2;
  688. this._ta.y = winSize.height / 2;
  689. this.addChild(this._ta, 10);
  690. this.addChild(this._roles, 11);
  691. this._helo = Helo.create();
  692. this._roles.addChild(this._helo);
  693. this._helo.y = winSize.height / 3;
  694. this._helo.x = winSize.width / 2;
  695. a = cc.textureCache.addImage(res.blood_png);
  696. this._blood = cc.SpriteBatchNode.create(a);
  697. this.addChild(this._blood);
  698. Light2.shared();
  699. Blood.shared();
  700. Enemy.preSet()
  701. },
  702. initData: function() {
  703. this._time = this._time2 = GD.MAXTIME;
  704. this._dataLayer = BitNumLayer.create();
  705. this.addChild(this._dataLayer, 100)
  706. },
  707. setLive: function(a) {
  708. this._ta.setLive(a)
  709. },
  710. enemyAttact: function(a, b) {
  711. this._state == STATE_PLAYING && (Light2.addNew(cc.pAdd(centerPos, cc.pMult(b, 30))), this.setLive(a))
  712. },
  713. killOneEnemy: function(a) {
  714. this._dataLayer.setNum(a.money);
  715. Blood.addNew(a.getPosition(), a.angle)
  716. },
  717. oneEnemyDie: function(a) {},
  718. initUserControl: function() {
  719. var a =
  720. this,
  721. b = cc.EventListener.create({
  722. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  723. swallowTouches: !1,
  724. onTouchBegan: function(b, e) {
  725. a._helo.setNewPot(b.getLocation());
  726. return !0
  727. },
  728. onTouchMoved: function(b, e) {
  729. a.moved && (a._helo.setNewPot(b.getLocation()), a.moved = !1)
  730. },
  731. onTouchEnded: function(a, b) {
  732. return !0
  733. }
  734. });
  735. cc.eventManager.addListener(b, this)
  736. },
  737. initBg: function() {
  738. this._bg = new cc.Sprite(res.bg);
  739. this._bg.x = winSize.width / 2;
  740. this._bg.y = winSize.height / 2;
  741. this._bg.anchorX = this._bg.anchorY = 0.5;
  742. this.addChild(this._bg, 0);
  743. var a = new cc.Sprite("#quan.png");
  744. this.addChild(a);
  745. a.x = winSize.width / 2;
  746. a.y = winSize.height / 2
  747. },
  748. addEnemy: function(a, b, c) {
  749. this._roles.addChild(a, b, c)
  750. },
  751. addBlood: function(a, b) {
  752. this._blood.addChild(a, b)
  753. },
  754. addLight: function(a, b) {
  755. this._blood.addChild(a, b)
  756. },
  757. addLight2: function(a, b) {
  758. this.addChild(a, 110)
  759. },
  760. toAddBlood: function(a) {},
  761. clockCounter2: function() {
  762. if (this._state == STATE_PLAYING)
  763. if (this._time2 -= 0.1, 0 > this._time2 && (this._time2 = 0), this._time = Math.floor(this._time2), this._time2 = Math.floor(10 * this._time2) / 10, GD.USETIME = GD.MAXTIME - this._time2,
  764. 0 >= this._space) {
  765. this.emyspd = 0.08 * Math.floor(GD.USETIME / 10);
  766. this.emyspd = 10 < this.emyspd ? 10 : this.emyspd;
  767. this._space = 10 - Math.floor(0.2 * GD.USETIME);
  768. var a = Math.floor(4 * Math.random());
  769. Enemy.addNewEnemy(a + 1, this.emyspd)
  770. } else this._space--
  771. },
  772. update: function(a) {
  773. this._state == STATE_PLAYING && (this.moved = !0, this.checkIsCollide(a), this.updateUI(), this.toReorderChild())
  774. },
  775. checkIsCollide: function(a) {
  776. var b, c = this._helo.getPosition(),
  777. e = {},
  778. d = !1;
  779. for (b = 0; b < GD.CONTAINER.ENEMIES.length; b++)
  780. if (a = GD.CONTAINER.ENEMIES[b], "run" ==
  781. a.state || "attact" == a.state) {
  782. a.update(e);
  783. var f = a.getPosition();
  784. 140 > cc.pDistance(c, f) && (d = cc.pNormalize(cc.pSub(f, c)), a.toBeHurt(1, d), d = !0)
  785. }
  786. d && shake.hitAndShake(this, 10, 10)
  787. },
  788. toReorderChild: function() {
  789. this._helo.y > winSize.height / 2 + 50 ? this.reorderChild(this._roles, 9) : this.reorderChild(this._roles, 11)
  790. },
  791. updateUI: function() {
  792. shake && shake.update();
  793. this._helo.update()
  794. },
  795. clearEmeny: function() {
  796. for (i = 0; i < GD.CONTAINER.ENEMIES.length; i++) {
  797. var a = GD.CONTAINER.ENEMIES[i];
  798. a && this._roles.removeChild(a)
  799. }
  800. GD.CONTAINER.ENEMIES = []
  801. },
  802. addRoad: function(a) {
  803. this.addChild(a, 0)
  804. },
  805. loseGame: function() {
  806. this._helo.toDie();
  807. this.toGameEnd()
  808. },
  809. winGame: function() {
  810. this.toGameEnd();
  811. this.onGameOver()
  812. },
  813. toGameEnd: function() {
  814. this._state = STATE_GAMEOVER;
  815. this.unschedule(this.clockCounter2, 0.1);
  816. cc.eventManager.removeAllListeners()
  817. },
  818. onGameOver: function() {
  819. this._state = STATE_GAMEOVER;
  820. this.clearEmeny();
  821. this._roles.removeAllChildren();
  822. this._blood.removeAllChildren();
  823. this._helo = null;
  824. cc.spriteFrameCache.removeSpriteFramesFromFile(res.role_plist);
  825. cc.spriteFrameCache.removeSpriteFramesFromFile(res.blood_plist);
  826. cc.spriteFrameCache.removeSpriteFramesFromFile(res.light_plist);
  827. cc.director.runScene(cc.TransitionFade.create(0.6, GameOverScene.create()))
  828. },
  829. reStart: function() {
  830. this.init()
  831. }
  832. }),
  833. GameScene = cc.Scene.extend({
  834. onEnter: function() {
  835. this._super();
  836. var a = new GameLayer;
  837. a.init();
  838. this.addChild(a)
  839. }
  840. });
  841. GameScene.create = function() {
  842. var a = new GameScene;
  843. return a && a.init() ? a : null
  844. };
  845. var GameOverLayer = cc.Layer.extend({
  846. _time: null,
  847. _bg: null,
  848. _scoreLabel: null,
  849. _sharelayer: null,
  850. _viewB: null,
  851. sharemenu: null,
  852. againmenu: null,
  853. downmenu: null,
  854. _commentLabel: null,
  855. _iconLabel: null,
  856. moremenu: null,
  857. ctor: function() {
  858. this._super()
  859. },
  860. init: function() {
  861. cc.spriteFrameCache.addSpriteFrames(res.gameover_plist);
  862. this.initBg();
  863. this.initMenu();
  864. var a = cc.Sprite.create(cc.tglogotexture2d);
  865. a.y = 70;
  866. a.anchorX = 0.5;
  867. a.x = winSize.width / 2;
  868. this.addChild(a)
  869. },
  870. initEvent: function() {
  871. var a = this,
  872. b = cc.EventListener.create({
  873. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  874. swallowTouches: !1,
  875. onTouchBegan: function(b, e) {
  876. var d = e.getCurrentTarget(),
  877. f = d.convertToNodeSpace(b.getLocation()),
  878. g = d.getContentSize(),
  879. g = cc.rect(0, 0, g.width, g.height);
  880. if (cc.rectContainsPoint(g, f)) {
  881. d.y -= 2;
  882. if (d == a.sharemenu) a.onShare();
  883. else if (d == a.againmenu) a.onAgain();
  884. else if (d == a.moremenu) a.onMore();
  885. return !0
  886. }
  887. return !1
  888. },
  889. onTouchEnded: function(a, b) {
  890. var d = b.getCurrentTarget();
  891. d.y += 2
  892. }
  893. });
  894. cc.eventManager.addListener(b, a.sharemenu);
  895. cc.eventManager.addListener(b.clone(), a.againmenu);
  896. cc.eventManager.addListener(b.clone(),
  897. a.moremenu)
  898. },
  899. initMenu: function() {
  900. this.sharemenu = cc.Sprite.create("#share.png");
  901. this.againmenu = cc.Sprite.create("#again.png");
  902. this.moremenu = cc.Sprite.create("#more.png");
  903. this.addChild(this.sharemenu);
  904. this.addChild(this.againmenu);
  905. this.addChild(this.moremenu);
  906. this._bg.x = winSize.width / 2;
  907. this._bg.y = winSize.height / 2 + 307 - 265.5 + 70;
  908. this._scoreLabel.x = this._bg.x;
  909. this._scoreLabel.y = this._bg.y - 50;
  910. this._commentLabel.y = this._bg.y - 130;
  911. this._commentLabel.x = this._bg.x + 90;
  912. this._iconLabel.x = this._bg.x + 30;
  913. this._iconLabel.y =
  914. this._bg.y - 188;
  915. this.sharemenu.x = this._bg.x + 138;
  916. this.againmenu.y = this.sharemenu.y = this._bg.y - 307 + 5;
  917. this.againmenu.x = this._bg.x - 138;
  918. this.moremenu.y = this._bg.y - 307 - 90;
  919. this.moremenu.x = this._bg.x;
  920. var a = this;
  921. setTimeout(function() {
  922. a.initEvent()
  923. }, 500)
  924. },
  925. initBg: function() {
  926. this._sharelayer = null;
  927. trace("initBg");
  928. var a = cc.DrawNode.create();
  929. this.addChild(a, 0);
  930. a.drawRect(cc.p(-56, -10), cc.p(800, winSize.height + 20), cc.color(25, 25, 25, 24), 0, 0);
  931. this._bg = new cc.Sprite("#over.png");
  932. this.addChild(this._bg);
  933. this._scoreLabel =
  934. cc.LabelAtlas.create("0", res.num_png, 65, 87, "0");
  935. this.addChild(this._scoreLabel);
  936. this._scoreLabel.anchorX = 0.5;
  937. this._scoreLabel.setString(GD.SCORE);
  938. this._commentLabel = cc.LabelTTF.create("", "Arial", 40);
  939. this.addChild(this._commentLabel);
  940. var b = "\u63d0\u83ab\u7684\u5de1\u903b\u5bc6\u6797 \u963f\u72f8\u7684\u9b45\u60d1\u7a7a\u95f4 \u5361\u7279\u7684\u523a\u6740\u4e4b\u9986 \u7490\u7490\u7684\u5947\u5e7b\u4ed9\u5883 \u7d22\u62c9\u5361\u661f\u5149\u5723\u5730 \u6cf0\u9686\u7684\u523a\u6740\u5730\u7262 \u83ab\u7518\u5a1c\u90aa\u7ffc\u82cd\u7a79 \u5e03\u5170\u5fb7\u6012\u7130\u7a7a\u95f4 \u827e\u5e0c\u7684\u8fdc\u89c1\u51b0\u539f \u76d6\u4f26\u7684\u519b\u56e2\u8425\u5730 \u7687\u5bb6\u6597\u6280\u573a \u8363\u8000\u89d2\u6597\u573a \u4f0a\u6cfd\u7684\u534e\u4e3d\u821e\u53f0 \u745e\u96ef\u7684\u6e38\u8361\u5e73\u539f \u6613\u7684\u65e0\u6781\u4e4b\u9986 \u8d3e\u514b\u65af\u7684\u89d2\u6597\u573a \u5d14\u4e1d\u5854\u5a1c\u7684\u8425\u5730 \u5b89\u59ae\u7684\u70c8\u7130\u4e50\u56ed".split(" "),
  941. c = Math.floor(GD.USETIME / 10),
  942. c = 6 < c ? 6 : c,
  943. a = "0\u4e2a \u82f1\u52c7\u9ec4\u94dc \u4e0d\u5c48\u767d\u94f6 \u8363\u8000\u9ec4\u91d1 \u534e\u8d35\u94c2\u91d1 \u7480\u74a8\u94bb\u77f3 \u6700\u5f3a\u738b\u8005".split(" ")[c];
  944. GD.SHARE = "\u6211\u5728\u5b88\u62a4\u6c34\u6676\u65f6\u83b7\u5f97\u4e86" + GD.SCORE + "\u5206\u548c" + a + "\u5fbd\u7ae0\uff0c\u4f60\u6765\u8bd5\u8bd5~";
  945. trace("num------------" + c + ":" + GD.SHARE);
  946. this._commentLabel.anchorX = 0.5;
  947. b = b[Math.floor(Math.random() * b.length)];
  948. this._commentLabel.setString("\u201c" +
  949. b + "\u201d");
  950. this._commentLabel.color = cc.color.YELLOW;
  951. this._iconLabel = cc.LabelTTF.create("", "Arial", 40);
  952. this._iconLabel.color = cc.color.YELLOW;
  953. this._iconLabel.anchorX = 0.5;
  954. this.addChild(this._iconLabel);
  955. this._iconLabel.setString(a);
  956. a = cc.LabelTTF.create("", "Arial", 40);
  957. b = cc.LabelTTF.create("", "Arial", 40);
  958. c = cc.LabelTTF.create("", "Arial", 40);
  959. a.anchorX = 0.5;
  960. b.anchorX = 0.5;
  961. c.anchorX = 0.5;
  962. this.addChild(a);
  963. this.addChild(b);
  964. this.addChild(c);
  965. a.setString("\u4e2d\u83b7\u5f97\u4e86");
  966. b.setString("\u5fbd\u7ae0!");
  967. c.setString("\u4f60\u5728\u9547\u5b88");
  968. a.x = winSize.width / 2 - 170;
  969. b.x = winSize.width / 2 + 185;
  970. c.x = winSize.width / 2 - 170;
  971. a.y = b.y = winSize.height / 2 - 75;
  972. c.y = winSize.height / 2 - 20
  973. },
  974. onAgain: function() {
  975. // pgvSendClick && "function" == typeof pgvSendClick && pgvSendClick({
  976. // hottag: "h5game.zgl.again"
  977. // });
  978. cc.spriteFrameCache.removeSpriteFramesFromFile(res.npc_plist);
  979. cc.director.runScene(cc.TransitionFade.create(0.3, MenuScene.create()))
  980. },
  981. onMore: function() {
  982. // pgvSendClick && "function" == typeof pgvSendClick && pgvSendClick({
  983. // hottag: "h5game.zgl.more"
  984. // });
  985. // window.open("http://tgideas.qq.com/weixin/works/game.shtml",
  986. // "_blank")
  987. },
  988. onShare: function() {
  989. // pgvSendClick && "function" == typeof pgvSendClick && pgvSendClick({
  990. // hottag: "h5game.zgl.sharebtn"
  991. // });
  992. cc.eventManager.removeAllListeners();
  993. trace("onShare");
  994. cc.director.runScene(ShareScene.create())
  995. },
  996. onOver: function() {}
  997. }),
  998. GameOverScene = cc.Scene.extend({
  999. onEnter: function() {
  1000. this._super();
  1001. var a = new GameOverLayer;
  1002. a.init();
  1003. this.addChild(a)
  1004. }
  1005. });
  1006. GameOverScene.create = function() {
  1007. var a = new GameOverScene;
  1008. return a && a.init() ? a : null
  1009. };
  1010. var ShareLayer = cc.Layer.extend({
  1011. _time: null,
  1012. _bg: null,
  1013. _scoreLabel: null,
  1014. menu: null,
  1015. listener4: null,
  1016. ctor: function() {
  1017. this._super()
  1018. },
  1019. init: function() {
  1020. this.initBg();
  1021. this.initMenu();
  1022. var a = cc.Sprite.create(cc.tglogotexture2d);
  1023. a.y = 70;
  1024. a.anchorX = 0.5;
  1025. a.x = winSize.width / 2;
  1026. this.addChild(a)
  1027. },
  1028. initMenu: function() {
  1029. this.menu = cc.Sprite.create("#return.png");
  1030. this.menu.x = winSize.width / 2;
  1031. this.menu.y = 180;
  1032. this.addChild(this.menu);
  1033. var a = this;
  1034. this.listener4 = cc.EventListener.create({
  1035. event: cc.EventListener.TOUCH_ONE_BY_ONE,
  1036. swallowTouches: !1,
  1037. onTouchBegan: function(a, c) {
  1038. var e = c.getCurrentTarget(),
  1039. d = e.convertToNodeSpace(a.getLocation()),
  1040. f = e.getContentSize(),
  1041. f = cc.rect(0, 0, f.width, f.height);
  1042. cc.rectContainsPoint(f, d) && (e.y -= 2);
  1043. return !0
  1044. },
  1045. onTouchEnded: function(b, c) {
  1046. a.onReturn()
  1047. }
  1048. });
  1049. cc.eventManager.addListener(this.listener4, this.menu)
  1050. },
  1051. onReturn: function() {
  1052. cc.eventManager.removeListener(this.listener4, this.menu);
  1053. cc.director.runScene(GameOverScene.create())
  1054. },
  1055. initBg: function() {
  1056. trace("initBg");
  1057. this._bg = new cc.Sprite(res.shareword);
  1058. this._bg.x = winSize.width /
  1059. 2;
  1060. this._bg.y = winSize.height / 2 + 200;
  1061. this.addChild(this._bg)
  1062. }
  1063. }),
  1064. ShareScene = cc.Scene.extend({
  1065. onEnter: function() {
  1066. this._super();
  1067. var a = new ShareLayer;
  1068. a.init();
  1069. this.addChild(a)
  1070. }
  1071. });
  1072. ShareScene.create = function() {
  1073. var a = new ShareScene;
  1074. return a && a.init() ? a : null
  1075. };
  1076. cc.game.onStart = function() {
  1077. cc.sys.isMobile ? cc.view.setDesignResolutionSize(640, 1008, cc.ResolutionPolicy.FIXED_HEIGHT) : cc.view.setDesignResolutionSize(640, 1008, cc.ResolutionPolicy.SHOW_ALL);
  1078. winSize = cc.director.getWinSize();
  1079. centerPos = cc.p(winSize.width / 2, winSize.height / 2);
  1080. cc.LoaderScene.preload(g_mainmenu, function() {
  1081. cc.director.runScene(MenuScene.create())
  1082. }, this)
  1083. }; /* |xGv00|47f21dad2466eb15234303109127fddd */