game.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import "./js/weapp-adapter";
  2. import { TweenMax } from './js/TweenMax.min'
  3. import * as PIXI from './js/pixi';
  4. import GD from './js/human.min'
  5. import gc from './js/GC'
  6. // @TODO 引入sdk代码
  7. import DwSdk from "./duowansdk/DwSdk";
  8. const debug = false;
  9. const objSdk = GD.objSdk = new DwSdk("精灵大拯救", debug);
  10. /*이미지 서버*/
  11. var GAME_IMG_PATH = 'https://pub.dwstatic.com/wxgame/jumpgame';
  12. /*JS 서버*/
  13. var RES_DIR_IMG = GAME_IMG_PATH + '/jumpgame_stair/image/';//메달 이미지가 있는 경우
  14. var RES_DIR_JSON = RES_DIR_IMG + 'json/';
  15. var RES_DIR_SPINE = RES_DIR_IMG + 'spine/';
  16. // 소스버전
  17. function mobileCheck() {
  18. var mobileKeyWords = ['iphone', 'ipod', 'blackberry', 'android', 'windows ce', 'lg', 'mot', 'samsung', 'sonyericsson', 'meego', 'nokia', 'webos', 'opera mini', 'opera mobi', 'iemobile'];
  19. gc.IS_MOBILE = false;
  20. var browerAgent = navigator.userAgent.toLowerCase();
  21. for (var i = 0; i < mobileKeyWords.length; ++i) {
  22. if (browerAgent.indexOf(mobileKeyWords[i]) != -1) {
  23. gc.IS_MOBILE = true;
  24. break;
  25. }
  26. }
  27. }
  28. function checkIphone() {
  29. var mobileKeyWords = ['iphone', 'ipod'];
  30. gc.IS_IPHONE = false;
  31. var browerAgent = navigator.userAgent.toLowerCase();
  32. for (var i = 0; i < mobileKeyWords.length; i++) {
  33. if (browerAgent.indexOf(mobileKeyWords[i]) != -1) {
  34. gc.IS_IPHONE = true;
  35. break;
  36. }
  37. }
  38. };
  39. //오브젝트 지우기
  40. function removeObject(obj) {
  41. //어디에 붙어있던 부모를 찾아서 지우므로 어디에 붙어있는지 몰라도 됨.
  42. if (obj && obj.parent) obj.parent.removeChild(obj);
  43. };
  44. // 인트로
  45. function onIntro() {
  46. //사운드 팝업
  47. if (!gc.soundPopup) gc.soundPopup = new gc.PopupSound();
  48. //개별 인트로
  49. if (gc.game) {
  50. TweenMax.killAll();
  51. removeObject(gc.game);
  52. }
  53. gc.game = null;
  54. objSdk.showAdIcon(10, 880);
  55. removeObject(gc.intro);
  56. gc.intro = null;
  57. if (!gc.intro) gc.intro = new gc.Intro();
  58. gc.intro.init();
  59. GD.stage.addChild(gc.intro);
  60. }
  61. /**
  62. * Created by admin on 2018-04-05.
  63. */
  64. (function () {
  65. var { pixelRatio, windowWidth, windowHeight } = wx.getSystemInfoSync()
  66. var gWidth = windowWidth * 2
  67. var gHeight = windowHeight * 2
  68. // 언어설정
  69. GD.leng = 'cn';
  70. GD.isDebug = false;
  71. // Canvas 화면설정
  72. GD.init(gWidth, gHeight, 0, 0, 0xFFFFFF);
  73. //모바일 체크
  74. mobileCheck();
  75. checkIphone();
  76. //이미지 로드
  77. loadImage();
  78. })();
  79. //이미지 로드
  80. function loadImage() {
  81. //메달 업적이미지
  82. // GD.loader.add('game_medal_1', RES_DIR_IMG + "mission_0001.png");
  83. //PNG 이미지 로드
  84. // GD.loader.add('game_bg1', RES_DIR_PNG + "bg1.png");
  85. //JSON 이미지 로드
  86. GD.loader.add(RES_DIR_JSON + "naver/" + "naver_result.json");
  87. GD.loader.add(RES_DIR_JSON + "popup/" + "popup_sound.json");
  88. GD.loader.add(RES_DIR_JSON + "popup/" + 'popup_menu.json');
  89. GD.loader.add(RES_DIR_JSON + "intro/" + "intro.json");
  90. GD.loader.add(RES_DIR_JSON + "game/" + "bg_1.json");
  91. GD.loader.add(RES_DIR_JSON + "game/" + "bg_2.json");
  92. GD.loader.add(RES_DIR_JSON + "game/" + "game_ui.json");
  93. //튜토리얼
  94. if (GD.leng == 'ko') { GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1.json"); }
  95. else { GD.loader.add(RES_DIR_JSON + "tutorial/" + "tutorial1_" + GD.leng + ".json"); }
  96. //spine 이미지 로드
  97. GD.loader.add('cha1', RES_DIR_SPINE + "character/" + "lyto.json");
  98. GD.loader.add('somi', RES_DIR_SPINE + "character/" + "somi.json");
  99. GD.loader.add('bird1', RES_DIR_SPINE + "bird/" + "bird.json");
  100. GD.loader.add('bird2', RES_DIR_SPINE + "bird/" + "bird2.json");
  101. GD.loader.add('bird3', RES_DIR_SPINE + "bird/" + "bird3.json");
  102. GD.loader.add('foothold1', RES_DIR_SPINE + "foothold/" + "foothold_1.json");
  103. GD.loader.add('foothold2', RES_DIR_SPINE + "foothold/" + "foothold_2.json");
  104. GD.loader.add('foothold_ice', RES_DIR_SPINE + "foothold/" + "foothold_ice.json");
  105. GD.loader.add('foothold_rail', RES_DIR_SPINE + "foothold/" + "foothold_rail.json");
  106. GD.loader.add('foothold_jump', RES_DIR_SPINE + "foothold/" + "foothold_jump.json");
  107. GD.loader.add('cha_hit', RES_DIR_SPINE + "effect/" + "cha_hit.json");
  108. GD.loader.add('ef1', RES_DIR_SPINE + "effect/" + "ef1.json");
  109. GD.loader.add('ef2', RES_DIR_SPINE + "effect/" + "ef2.json");
  110. GD.loader.add('target', RES_DIR_SPINE + "effect/" + "target.json");
  111. GD.loader.add('scoreEf50', RES_DIR_SPINE + "effect/" + "text2.json");
  112. GD.loader.add('scoreEf100', RES_DIR_SPINE + "effect/" + "text3.json");
  113. GD.loader.add('scoreEf1000', RES_DIR_SPINE + "effect/" + "firework.json");
  114. GD.loader.add('portal1', RES_DIR_SPINE + "portal/" + "portal1.json");
  115. //사운드 로드
  116. GD.loader.load(loadSound);
  117. GD.showProgress();
  118. }
  119. //사운드 로드
  120. function loadSound() {
  121. //bgm
  122. var soundList = [
  123. 'sound_bgm_mini'
  124. // 'sound_50'
  125. ];
  126. //effect
  127. var effectList = [
  128. 'sound_50',
  129. 'sound_100',
  130. 'sound_1000',
  131. 'sound_gauge',
  132. 'sound_jump',
  133. 'sound_newblock',
  134. 'sound_newtheme',
  135. 'sound_start',
  136. 'sound_wallhit',
  137. 'sound_birdhit',
  138. 'sound_dangling',
  139. 'sound_falling',
  140. 'sound_clear',
  141. 'sound_gameover'
  142. ];
  143. if (GD.soundType == 1) soundList = soundList.concat(effectList);//bgm과 이펙트 사운드가 분리되어 관리될 경우 하나의 배열로 합침
  144. if (soundList.length == 0) {
  145. onAssetsLoaded();
  146. return;
  147. }
  148. GD.loadSound(soundList, onAssetsLoaded);
  149. }
  150. //로드 완료
  151. function onAssetsLoaded() {
  152. console.log('assets loaded')
  153. // 로딩화면 삭제
  154. GD.hideProgress();
  155. onIntro();
  156. GD.app.ticker.add(objSdk.update, null, PIXI.UPDATE_PRIORITY.UTILITY);
  157. }
  158. wx.onShareAppMessage(function () {
  159. return {
  160. title: "聪明人都在玩的游戏,快来挑战一下!",
  161. imageUrl: "https://pub.dwstatic.com/wxgame/jumpgame/jumpgame_stair/image/json/intro/shareImage.jpg",
  162. query: ""
  163. }
  164. })
  165. wx.showShareMenu({
  166. withShareTicket: false
  167. })