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