张延森 3 years ago
parent
commit
c028ceaacc
1 changed files with 12 additions and 5 deletions
  1. 12
    5
      src/pages/game/game.js

+ 12
- 5
src/pages/game/game.js View File

80
   // 目标轿厢与子弹轿厢的映射字典
80
   // 目标轿厢与子弹轿厢的映射字典
81
   const mntMap = {}
81
   const mntMap = {}
82
 
82
 
83
+  
84
+  // 修复一个单页面应用, 不能重复加载图片的bug
85
+  Two.Texture.ImageRegistry = new Two.Registry();
86
+
83
   // 初始化
87
   // 初始化
84
   let two = new Two({
88
   let two = new Two({
89
+    type: Two.Types.svg,
85
     fullscreen: true,
90
     fullscreen: true,
86
-    autostart: true
87
   }).appendTo(el);
91
   }).appendTo(el);
88
 
92
 
89
   // 绘制背景
93
   // 绘制背景
372
   }
376
   }
373
   el.addEventListener('click', handleClick);
377
   el.addEventListener('click', handleClick);
374
 
378
 
379
+
380
+  two.update();
381
+  two.play();
382
+  console.log('-------twotwotwo--------')
383
+
375
   return {
384
   return {
376
     two,
385
     two,
377
     raduis,
386
     raduis,
381
     stop: () => {
390
     stop: () => {
382
       isFinished = true;
391
       isFinished = true;
383
     },
392
     },
384
-    destroy: () => {    
393
+    destroy: () => {
385
       two.unbind('update');
394
       two.unbind('update');
386
       two.pause();
395
       two.pause();
387
-      two.clear();
388
       el.removeChild(two.renderer.domElement);
396
       el.removeChild(two.renderer.domElement);
389
       el.removeEventListener('click', handleClick);
397
       el.removeEventListener('click', handleClick);
390
       two = null;
398
       two = null;
391
-      Two.Instances.pop()
392
     }
399
     }
393
   }
400
   }
394
 }
401
 }
404
     bgBox.width = bgTexture.image.naturalWidth;
411
     bgBox.width = bgTexture.image.naturalWidth;
405
     bgBox.height = bgTexture.image.naturalHeight;
412
     bgBox.height = bgTexture.image.naturalHeight;
406
     bgBox.scale = scale;
413
     bgBox.scale = scale;
407
-  })
414
+  }) 
408
 }
415
 }