123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- "use strict";
- cc._RF.push(module, 'e7bb6jSzFdAkZ3NE9UU0vuC', 'GameAudio');
- // Script/GameAudio.js
- "use strict";
- /**
- * Player场景声音控制
- */
- // let GameEvent = require('GameEvent');
- var GameEvent = require('GameEvent');
- cc.Class({
- "extends": cc.Component,
- editor: {
- menu: 'GameAudio(游戏声音脚本)'
- },
- properties: {
- bgmClip: {
- type: cc.AudioClip,
- "default": null
- },
- //背景音乐
- wowClip: {
- type: cc.AudioClip,
- "default": null
- },
- //过关音效
- startClip: {
- type: cc.AudioClip,
- "default": null
- },
- //开始音效
- selectClip: {
- type: cc.AudioClip,
- "default": null
- },
- //选中音效
- brokens: {
- type: cc.AudioClip,
- "default": []
- },
- //消除音效
- popClip: {
- type: cc.AudioClip,
- "default": null
- }
- },
- start: function start() {
- var _this = this;
- zy.playBgMusic(this.bgmClip, true);
- zy.playSound(this.startClip); //矩阵事件监听
- cc.game.on(GameEvent.EventType.GAME_CLEAR_COUNT, function (count) {
- var index = Math.min(count - 1, _this.brokens.length - 1);
- if (index >= 0) {
- zy.playSound(_this.brokens[index]);
- _this._playPopEffect(count);
- }
- }, this); //过关
- cc.game.on(GameEvent.EventType.GAME_PASS_STAGE, function () {
- zy.playSound(_this.wowClip);
- }, this);
- },
- _playPopEffect: function _playPopEffect(count) {
- var _this2 = this;
- var index = 0;
- var playPopClip = function playPopClip() {
- ++index;
- zy.playSound(_this2.popClip);
- if (index >= count) {
- _this2.unschedule(playPopClip);
- }
- };
- this.schedule(playPopClip, 0.08);
- },
- onDestroy: function onDestroy() {
- //关闭所有音乐、音效
- cc.audioEngine.stopAll(); //移除所有事件监听
- cc.game.targetOff(this);
- }
- });
- cc._RF.pop();
|