Commit b4bbd46e authored by XieChuanJin's avatar XieChuanJin

增加音效

parent 6c541e0f
......@@ -31,7 +31,7 @@
<div id="game-container" style="line-height:0;font-size:0"></div>
<script src="//res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
<!--script src="http://localhost:4002/debug/engine.js"></script-->
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.a55406676ddead0c1728d886fa14378bbf82d873.js"></script>
<script src="//yun.duiba.com.cn/editor/zeroing/libs/engine.d208e8f972669861e966f1cfe979ad7700cb1f8d.js"></script>
<script src="app.js"></script>
<script>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -80,7 +80,7 @@ export default class Ball extends MoveObjcet implements PoolElement {
}
EffectMgr.playBoomEffect(this.position, this.scaleRatio);
SoundMgr.instance.playEffect("boom_mp3");
SoundMgr.instance.playEffect("boom");
ballPool.recycle(this.poolKey, this);
}
......@@ -196,7 +196,7 @@ export default class Ball extends MoveObjcet implements PoolElement {
//判断是否会震动地面
if (this.sizeIndex >= MConfigs.size.length - 2) {
DataMgr.game._shake();
SoundMgr.instance.playEffect("dong_mp3");
SoundMgr.instance.playEffect("dong");
}
}
......
......@@ -61,7 +61,7 @@ export default class Car extends GameObject {
private fire() {
// return;
SoundMgr.instance.playEffect("shoot_mp3");
SoundMgr.instance.playEffect("shoot");
new BulletGroup(new engine.Point(this.x + this.width / 2, this.y), this.rowBulletNum);
}
......
......@@ -63,7 +63,7 @@ export default class Drop extends MoveObjcet implements PoolElement {
}
private eated() {
SoundMgr.instance.playEffect("collect_mp3");
SoundMgr.instance.playEffect("collect");
this.physics.rotateVelocity = 0;
DropBlinkMgr.instance.remove(this);
this.visible = true;
......
......@@ -165,8 +165,8 @@ export default class Game {
//开始倒计时
this.timing = true;
// this._BulletScore = 140;
// this._PowerScore = 2000;
this._BulletScore = 140;
this._PowerScore = 2000;
}
public addGameObject(gameObject: GameObject, layer: LayerName) {
......@@ -225,6 +225,7 @@ export default class Game {
private createBall() {
return;
let size = MUtils.randomInt(0, MConfigs.size.length);
if (GuideMgr.instance.guideFlag == true) {
size = 3;
......
......@@ -9,11 +9,10 @@ export default class SoundMgr {
return this._instance;
}
public effectEnabled = false;
private effectEnabled = false;
private _enabled: boolean = false;
public set enabled(v: boolean) {
this.musicEnabled = v;
// this.musicEnabled = v;
this.effectEnabled = v;
this._enabled = v;
}
......@@ -21,99 +20,20 @@ export default class SoundMgr {
return this._enabled;
}
private _musicEnabled: boolean = false;
public get musicEnabled() {
return this._musicEnabled;
}
public set musicEnabled(v: boolean) {
if (v == true) {
this.playMusic();
} else {
this.stopMusic();
}
this._musicEnabled = v;
}
// private music: engine. = null;
// private musicChannel: engine.SoundChannel = null;
// private loopChannelMap: { [name: string]: engine.SoundChannel } = {}
private effectPool: { [name: string]: PoolSound[] } = {}
public firstSeted = false;
public setMusic(url: string) {
// this.music = RES.getRes(url);
}
public playMusic() {
/* if (this.music == null) {
console.warn("music do not set");
return;
}
this.musicChannel && this.musicChannel.stop();
this.musicChannel = this.music.play(0, 0); */
}
public stopMusic() {
// this.musicChannel && (this.musicChannel.stop());
}
public playEffect(name: string, loop: boolean = false) {
/* if (!this.effectEnabled) return;
if (!this.effectEnabled) return;
let poolSound = this.createSound(name, loop);
let channel = poolSound.sound.play(0, loop ? 0 : 1);
if (loop) {
if (this.loopChannelMap[name]) {
this.loopChannelMap[name].stop();
}
this.loopChannelMap[name] = channel;
} else {
return new Promise<void>(resolve => {
channel.addEventListener(engine.Event.SOUND_COMPLETE, () => {
this.recycleSound(poolSound);
resolve();
}, this);
});
} */
engine.playSound(nameToUuid[name], {
loop: false
}, name);
}
public stopLoopEffect(name: string) {
/* if (this.loopChannelMap[name]) {
this.loopChannelMap[name].stop();
} */
}
private t: number = 0;
private createSound(name: string, loop: boolean): PoolSound {
/* let soundList = this.effectPool[name];
if (!soundList || soundList.length <= 0) {
let poolSound = new PoolSound(name, RES.getRes(name), loop);
if (poolSound.name == "shoot_mp3") {
this.t++;
}
return poolSound;
} else {
return soundList.pop();
} */
return null;
}
private recycleSound(poolSound: PoolSound) {
/* delete this.loopChannelMap[poolSound.name];
this.effectPool[poolSound.name] = this.effectPool[poolSound.name] || [];
this.effectPool[poolSound.name].push(poolSound); */
}
}
class PoolSound {
/* private loop = false;
public onRecycle = (sound: PoolSound) => { }
public sound: engine.Sound = null;
public name: string = null;
constructor(name: string, sound: engine.Sound, loop: boolean) {
this.name = name;
this.sound = sound;
this.loop = loop;
} */
const nameToUuid = {
shoot: "b01dc39a-2886-4887-b3bb-0f8c801003a9",
collect: "7004616a-0aba-4826-9245-895e7fdf8d31",
dong: "7fc04e43-1465-4336-92a3-d6039ee88cb3",
boom: "ca6b799f-be85-4e94-99df-812f31801490"
}
\ No newline at end of file
import { Pool, PoolGroup } from "../Component/Pool";
import Ball from "../Game/Ball";
import Game from "../Game/Game";
import { DataMgr } from "../Mgr/DataMgr";
class BallPool extends Pool<Ball>{
......
......@@ -17,6 +17,7 @@ import { NetUtils } from "./Global/NetUtils";
import Net from "./Global/Net";
import Loading from "./Global/Loading";
import { initNECaptcha } from "./Component/InitNECaptcha";
import SoundMgr from "./Mgr/SoundMgr";
/**
* Created by rockyl on 2019-11-22.
......@@ -50,6 +51,8 @@ export class ShootPlanet extends engine.Container {
constructor() {
super();
return;
this.customProperty();
this.game = new Game(this);
this.width = 750;
......@@ -57,6 +60,8 @@ export class ShootPlanet extends engine.Container {
this.addEventListener(engine.Event.REMOVED_FROM_STAGE, this.onDestroy, this);
this.init();
SoundMgr.instance.enabled = false;
if (GuideMgr.instance.guideFlag == true) {
const car = this.game._car;
GuideMgr.instance.runGuide(0, car.x + car.width / 2, car.y + car.height / 2 /* - 130 */);
......
......@@ -67,7 +67,7 @@
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/b95848ec6c510347c040f0c11f0d5685fcc110aa.png",
"url": "//yun.duiba.com.cn/aurora/assets/692cd00552482f0a89602701a84bde870019a763.png",
"uuid": "09bdff41-2fe3-4298-ad3a-1d2eaf6af778",
"ext": ".png"
},
......@@ -216,11 +216,6 @@
"uuid": "",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/d4ac501c938e2b7cd4beaf737ff07c53afe18c44.png",
"uuid": "3cc0aa86-0581-4caa-b662-266e58fd39b7",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/905239e8db76682f47339668e7d9279b2ec4f0e2.png",
"uuid": "93992a62-e3c4-46d5-99f4-f7ba35fe4f4f",
......@@ -260,7 +255,16 @@
"url": "//yun.duiba.com.cn/aurora/assets/ed6f41a38d28e03acf791dd3672c0364e6754821.mp3",
"uuid": "ca6b799f-be85-4e94-99df-812f31801490",
"ext": ".mp3"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/d4ac501c938e2b7cd4beaf737ff07c53afe18c44.png",
"uuid": "3cc0aa86-0581-4caa-b662-266e58fd39b7",
"ext": ".png"
},
{
"url": "//yun.duiba.com.cn/aurora/assets/d4ac501c938e2b7cd4beaf737ff07c53afe18c44.png",
"uuid": "3cc0aa86-0581-4caa-b662-266e58fd39b7",
"ext": ".png"
}
]
}
\ No newline at end of file
let payload = Object.assign({}, args);
let sign = engine.env.shareUrl.indexOf("?") > 0 ? "&" : "?";
payload.url = engine.env.shareUrl + sign + "shareCode=" + args.shareCode;
next('success', payload);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment