Commit 458393dd authored by zjz1994's avatar zjz1994

新加声音

parent beb4bf2e
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -31,4 +31,4 @@ export function createSvga(name, anchorName) { ...@@ -31,4 +31,4 @@ export function createSvga(name, anchorName) {
export function playSound(name) { export function playSound(name) {
engine.playSound(getAssetByName(name).uuid, {keep: true}); engine.playSound(getAssetByName(name).uuid, {keep: true});
} }
\ No newline at end of file
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
function injectProps(p) { function injectProps(p) {
engine.injectProp(props, p); engine.injectProp(props, p);
} }
//# sourceMappingURL=props.js.map
function getTexture(uuid) { function getTexture(uuid) {
return engine.Texture.from(getAssetByUUID(uuid).uuid); return engine.Texture.from(getAssetByUUID(uuid).uuid);
...@@ -20,12 +19,14 @@ ...@@ -20,12 +19,14 @@
function getTextureByName(name) { function getTextureByName(name) {
return getTexture(engine.getAssetByName(name).uuid); return getTexture(engine.getAssetByName(name).uuid);
} }
function playSound(name) {
engine.playSound(engine.getAssetByName(name).uuid, { keep: true });
}
function createSvga(name, anchorName) { function createSvga(name, anchorName) {
var inst = new svga.Svga(); var inst = new svga.Svga();
inst.source = 'asset://' + engine.getAssetByName(name).uuid; inst.source = 'asset://' + engine.getAssetByName(name).uuid;
return inst; return inst;
} }
//# sourceMappingURL=utils.js.map
var Element = (function (_super) { var Element = (function (_super) {
tslib.__extends(Element, _super); tslib.__extends(Element, _super);
...@@ -150,7 +151,6 @@ ...@@ -150,7 +151,6 @@
}; };
return Element; return Element;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=Element.js.map
var ElementType; var ElementType;
(function (ElementType) { (function (ElementType) {
...@@ -394,7 +394,6 @@ ...@@ -394,7 +394,6 @@
]; ];
return MapData; return MapData;
}()); }());
//# sourceMappingURL=MapData.js.map
var boomAni = (function (_super) { var boomAni = (function (_super) {
tslib.__extends(boomAni, _super); tslib.__extends(boomAni, _super);
...@@ -474,7 +473,6 @@ ...@@ -474,7 +473,6 @@
}; };
return boomAni; return boomAni;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=boomAni.js.map
var GameView = (function (_super) { var GameView = (function (_super) {
tslib.__extends(GameView, _super); tslib.__extends(GameView, _super);
...@@ -498,6 +496,7 @@ ...@@ -498,6 +496,7 @@
_this.elitype = 1; _this.elitype = 1;
_this.inguide = false; _this.inguide = false;
_this.diseffectArr = []; _this.diseffectArr = [];
_this.mute = 1;
_this._seq = 1; _this._seq = 1;
_this.sptime = Date.now(); _this.sptime = Date.now();
_this.useBoom = false; _this.useBoom = false;
...@@ -623,12 +622,13 @@ ...@@ -623,12 +622,13 @@
}; };
GameView.prototype.playComp = function () { GameView.prototype.playComp = function () {
}; };
GameView.prototype.init = function (time, level, mode) { GameView.prototype.init = function (time, level, mode, mute) {
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.level = level; this.level = level;
this.ingameover = false; this.ingameover = false;
this.mute = mute;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
this.sptime = Date.now(); this.sptime = Date.now();
...@@ -693,11 +693,11 @@ ...@@ -693,11 +693,11 @@
return tslib.__awaiter(this, void 0, void 0, function () { return tslib.__awaiter(this, void 0, void 0, function () {
return tslib.__generator(this, function (_a) { return tslib.__generator(this, function (_a) {
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.gamestat = 1;
this.selectArr = new Array(); this.selectArr = new Array();
this.gametime = time; this.gametime = time;
this.level = level; this.level = level;
this.ingameover = false; this.ingameover = false;
this.requestGameOver = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.changeEnable(false); this.changeEnable(false);
...@@ -723,7 +723,7 @@ ...@@ -723,7 +723,7 @@
}; };
GameView.prototype.onUpdate = function () { GameView.prototype.onUpdate = function () {
var ntime = Date.now(); var ntime = Date.now();
if (this.gamestat == 1 && this.ingame && !this.inguide) { if (this.gamestat == 1 && this.ingame && !this.inguide && !this.requestGameOver) {
var passtime = ntime - this.lastframeTime; var passtime = ntime - this.lastframeTime;
if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) { if (ntime - this.lastatime >= 5000 && !this.ination && this.canation && this.selectArr.length == 0) {
this.attionEliShow(); this.attionEliShow();
...@@ -1019,6 +1019,7 @@ ...@@ -1019,6 +1019,7 @@
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.inEliminate = true; this.inEliminate = true;
this.playEffect("消除音效");
for (i = 0; i < this.eliminateArr.length; i++) { for (i = 0; i < this.eliminateArr.length; i++) {
ielidata1 = this.eliminateArr[i]; ielidata1 = this.eliminateArr[i];
ielileng = ielidata1.length; ielileng = ielidata1.length;
...@@ -1868,6 +1869,7 @@ ...@@ -1868,6 +1869,7 @@
GameView.prototype.changeHomeShow = function (mode) { GameView.prototype.changeHomeShow = function (mode) {
}; };
GameView.prototype.boomeEle = function (row, col) { GameView.prototype.boomeEle = function (row, col) {
this.playEffect("爆炸音效");
this.unShowEleAttion(); this.unShowEleAttion();
this.useBoom = false; this.useBoom = false;
engine.globalEvent.dispatchEvent('game-useboomafter', {}); engine.globalEvent.dispatchEvent('game-useboomafter', {});
...@@ -1995,6 +1997,11 @@ ...@@ -1995,6 +1997,11 @@
this.diseffectArr.push(target); this.diseffectArr.push(target);
} }
}; };
GameView.prototype.playEffect = function (sound) {
if (this.mute == 1) {
playSound(sound);
}
};
return GameView; return GameView;
}(engine.Container)); }(engine.Container));
...@@ -2018,7 +2025,8 @@ ...@@ -2018,7 +2025,8 @@
var time = event.data.time; var time = event.data.time;
var level = event.data.level; var level = event.data.level;
var mode = event.data.mode; var mode = event.data.mode;
this._gameView.init(time, level, mode); var mute = event.data.mute;
this._gameView.init(time, level, mode, mute);
}; };
GameWrapper.prototype.reset = function (event) { GameWrapper.prototype.reset = function (event) {
var time = event.data.time; var time = event.data.time;
...@@ -2047,7 +2055,6 @@ ...@@ -2047,7 +2055,6 @@
}; };
return GameWrapper; return GameWrapper;
}(engine.Container)); }(engine.Container));
//# sourceMappingURL=GameWrapper.js.map
function index (props) { function index (props) {
prepareProps(); prepareProps();
...@@ -2055,7 +2062,6 @@ ...@@ -2055,7 +2062,6 @@
var instance = new GameWrapper(); var instance = new GameWrapper();
return instance; return instance;
} }
//# sourceMappingURL=index.js.map
return index; return index;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -90,6 +90,18 @@ ...@@ -90,6 +90,18 @@
"url": "//yun.duiba.com.cn/aurora/assets/e200b34d25020bd1d5430cf6f3e52c6866826076.png", "url": "//yun.duiba.com.cn/aurora/assets/e200b34d25020bd1d5430cf6f3e52c6866826076.png",
"uuid": "shine2", "uuid": "shine2",
"ext": ".png" "ext": ".png"
},
{
"name": "爆炸音效",
"url": "//yun.duiba.com.cn/aurora/assets/0223fe1440f0935aa3e9084ad7fa7808ec9f893c.mp3",
"uuid": "boomsound",
"ext": ".mp3"
},
{
"name": "消除音效",
"url": "//yun.duiba.com.cn/aurora/assets/becd6a758767b7bf75738dd5346f7ce84979c1fb.mp3",
"uuid": "elisound",
"ext": ".mp3"
} }
], ],
"events": { "events": {
......
...@@ -84,7 +84,8 @@ export default class GameView extends engine.Container { ...@@ -84,7 +84,8 @@ export default class GameView extends engine.Container {
//手指动效 //手指动效
shoueffect; shoueffect;
diseffectArr:Array<any> = []; diseffectArr:Array<any> = [];
//mute
mute = 1;//声音默认开启
set gamestat(stat){//1游戏中,2,游戏外 set gamestat(stat){//1游戏中,2,游戏外
this._gamestat = stat; this._gamestat = stat;
if(stat==2){ if(stat==2){
...@@ -292,12 +293,14 @@ export default class GameView extends engine.Container { ...@@ -292,12 +293,14 @@ export default class GameView extends engine.Container {
// this.homeimgnight.stop(1); // this.homeimgnight.stop(1);
} }
init(time,level,mode){ init(time,level,mode,mute){
this.score = 0; this.score = 0;
this.gametime = time; this.gametime = time;
this.seq = 1; this.seq = 1;
this.level = level; this.level = level;
this.ingameover = false; this.ingameover = false;
this.mute = mute;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.initContainer(); this.initContainer();
this.sptime = Date.now(); this.sptime = Date.now();
...@@ -358,11 +361,11 @@ export default class GameView extends engine.Container { ...@@ -358,11 +361,11 @@ export default class GameView extends engine.Container {
levelData; levelData;
async reset(time,level,mode){ async reset(time,level,mode){
this.anicontainer.removeChild(this.selectimg); this.anicontainer.removeChild(this.selectimg);
this.gamestat = 1;
this.selectArr = new Array(); this.selectArr = new Array();
this.gametime = time; this.gametime = time;
this.level = level; this.level = level;
this.ingameover = false; this.ingameover = false;
this.requestGameOver = false;
this.seq = 1; this.seq = 1;
this.changeHomeShow(mode); this.changeHomeShow(mode);
this.changeEnable(false); this.changeEnable(false);
...@@ -397,6 +400,7 @@ export default class GameView extends engine.Container { ...@@ -397,6 +400,7 @@ export default class GameView extends engine.Container {
start(){ start(){
console.log("game-start"); console.log("game-start");
this.gamestat = 1; this.gamestat = 1;
this.requestGameOver = false; this.requestGameOver = false;
this.selectArr = new Array(); this.selectArr = new Array();
this.changeEnable(true); this.changeEnable(true);
...@@ -413,7 +417,7 @@ export default class GameView extends engine.Container { ...@@ -413,7 +417,7 @@ export default class GameView extends engine.Container {
} }
onUpdate(){ onUpdate(){
let ntime = Date.now(); let ntime = Date.now();
if(this.gamestat==1&&this.ingame&&!this.inguide){ if(this.gamestat==1&&this.ingame&&!this.inguide&&!this.requestGameOver){
let passtime = ntime - this.lastframeTime; let passtime = ntime - this.lastframeTime;
if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){ if(ntime-this.lastatime>=5000&&!this.ination&&this.canation&&this.selectArr.length==0){
this.attionEliShow(); this.attionEliShow();
...@@ -768,6 +772,7 @@ export default class GameView extends engine.Container { ...@@ -768,6 +772,7 @@ export default class GameView extends engine.Container {
//消除 //消除
async eliminate(){ async eliminate(){
this.inEliminate = true; this.inEliminate = true;
this.playEffect("消除音效");
for(let i=0;i<this.eliminateArr.length;i++){ for(let i=0;i<this.eliminateArr.length;i++){
let ielidata1 = this.eliminateArr[i]; let ielidata1 = this.eliminateArr[i];
let ielileng = ielidata1.length; let ielileng = ielidata1.length;
...@@ -1712,6 +1717,7 @@ export default class GameView extends engine.Container { ...@@ -1712,6 +1717,7 @@ export default class GameView extends engine.Container {
//使用炸弹 //使用炸弹
boomeEle(row,col){ boomeEle(row,col){
this.playEffect("爆炸音效");
this.unShowEleAttion(); this.unShowEleAttion();
this.useBoom = false; this.useBoom = false;
//炸弹使用完毕 //炸弹使用完毕
...@@ -1859,4 +1865,10 @@ export default class GameView extends engine.Container { ...@@ -1859,4 +1865,10 @@ export default class GameView extends engine.Container {
this.diseffectArr.push(target); this.diseffectArr.push(target);
} }
} }
//音效播放
playEffect(sound:string){
if(this.mute==1){
playSound(sound);
}
}
} }
...@@ -29,7 +29,8 @@ export class GameWrapper extends engine.Container { ...@@ -29,7 +29,8 @@ export class GameWrapper extends engine.Container {
let time = event.data.time; let time = event.data.time;
let level = event.data.level; let level = event.data.level;
let mode = event.data.mode; let mode = event.data.mode;
this._gameView.init(time,level,mode); let mute = event.data.mute;
this._gameView.init(time,level,mode,mute);
} }
reset(event:engine.Event){ reset(event:engine.Event){
// console.log("gamewrapper-reset",event); // console.log("gamewrapper-reset",event);
......
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