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