58e3cacf-3a62-439b-af8c-d2bf2d295f7a.js
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"use strict";
cc._RF.push(module, '58e3crPOmJDm6+M0r8tKV96', 'SoundEffectButton');
// script/common/components/SoundEffectButton.ts
"use strict";
// Learn TypeScript:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/typescript.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
const GameBasicSettings_1 = require("../gameplay/settings/GameBasicSettings");
const { ccclass, property } = cc._decorator;
let SoundEffectButton = /** @class */ (() => {
let SoundEffectButton = class SoundEffectButton extends cc.Component {
constructor() {
super(...arguments);
this.clip = null;
this.interactable = true;
// update (dt) {}
}
// LIFE-CYCLE CALLBACKS:
onLoad() {
}
onEnable() {
this.node.on(cc.Node.EventType.TOUCH_END, this.onPlaySoundEffectCallback, this);
}
onDisable() {
this.node.off(cc.Node.EventType.TOUCH_END, this.onPlaySoundEffectCallback, this);
}
onPlaySoundEffectCallback(event) {
if (!this.clip) {
console.log("current clip is null.");
}
else if (this.interactable) {
if (GameBasicSettings_1.GameBasicSettings.soundVolume != 0)
cc.audioEngine.playEffect(this.clip, false);
}
}
start() {
}
};
__decorate([
property({ type: cc.AudioClip })
], SoundEffectButton.prototype, "clip", void 0);
SoundEffectButton = __decorate([
ccclass
], SoundEffectButton);
return SoundEffectButton;
})();
exports.default = SoundEffectButton;
cc._RF.pop();