Commit b3f4910c authored by haiyoucuv's avatar haiyoucuv

上传

parent 36b06aff
import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc'; import { _decorator, Button, Component, Node, Sprite, SpriteFrame } from 'cc';
import { AudioMgr } from "../../core_tgx/base/AudioMgr";
const {ccclass, property} = _decorator; const {ccclass, property} = _decorator;
...@@ -14,6 +15,12 @@ export class MusicBtn extends Component { ...@@ -14,6 +15,12 @@ export class MusicBtn extends Component {
set open(open: boolean) { set open(open: boolean) {
this._open = open; this._open = open;
this.sp.spriteFrame = open ? this.openSf : this.closeSf; this.sp.spriteFrame = open ? this.openSf : this.closeSf;
if (open) {
AudioMgr.ins.resume();
} else {
AudioMgr.ins.pause();
}
} }
get open() { get open() {
...@@ -22,11 +29,16 @@ export class MusicBtn extends Component { ...@@ -22,11 +29,16 @@ export class MusicBtn extends Component {
onLoad() { onLoad() {
this.sp = this.getComponent(Sprite); this.sp = this.getComponent(Sprite);
this.node.on(Button.EventType.CLICK, this.clickNode, this);
} }
start() { start() {
this.open = true; this.open = true;
} }
clickNode() {
this.open = !this.open;
}
} }
...@@ -10,6 +10,7 @@ import GameMgr from "../GameMgr"; ...@@ -10,6 +10,7 @@ import GameMgr from "../GameMgr";
import RankPanel from "../Panels/RankPanel"; import RankPanel from "../Panels/RankPanel";
import { UIMgr } from "../../Module/UIMgr"; import { UIMgr } from "../../Module/UIMgr";
import { AudioMgr } from "../../core_tgx/base/AudioMgr"; import { AudioMgr } from "../../core_tgx/base/AudioMgr";
import BackPanel from "../Panels/BackPanel";
const {ccclass, property} = _decorator; const {ccclass, property} = _decorator;
...@@ -78,7 +79,7 @@ export class HomeScene extends Scene { ...@@ -78,7 +79,7 @@ export class HomeScene extends Scene {
}); });
clickBack = _asyncThrottle(() => { clickBack = _asyncThrottle(() => {
// popWindow(); showPanel(BackPanel);
}); });
} }
......
...@@ -62,7 +62,7 @@ export class AudioMgr { ...@@ -62,7 +62,7 @@ export class AudioMgr {
* @param sound clip or url for the audio * @param sound clip or url for the audio
* @param volume * @param volume
*/ */
playOneShot(sound: AudioClip | string, volume: number = 1.0, bundleName: string = 'resources') { playOneShot(sound: AudioClip | string, volume: number = 1, bundleName: string = 'resources') {
if (sound instanceof AudioClip) { if (sound instanceof AudioClip) {
this._audioSource.volume = 1.0; this._audioSource.volume = 1.0;
this._audioSource.playOneShot(sound, volume * this._soundVolume); this._audioSource.playOneShot(sound, volume * this._soundVolume);
...@@ -89,7 +89,7 @@ export class AudioMgr { ...@@ -89,7 +89,7 @@ export class AudioMgr {
* @param volume * @param volume
* @param bundleName * @param bundleName
*/ */
play(sound: AudioClip | string, loop: boolean = false, volume: number = 1.0, bundleName: string = 'resources') { play(sound: AudioClip | string, loop: boolean = false, volume: number = 1, bundleName: string = 'resources') {
this._musicVolumeScale = volume; this._musicVolumeScale = volume;
if (sound instanceof AudioClip) { if (sound instanceof AudioClip) {
this._audioSource.clip = sound; this._audioSource.clip = sound;
......
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 98, "y": 165.149,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
"_target": null, "_target": null,
"_left": 108, "_left": 108,
"_right": 0, "_right": 0,
"_top": 470, "_top": 402.851,
"_bottom": 0, "_bottom": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -279,8 +279,8 @@ ...@@ -279,8 +279,8 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": -153.50000000000006, "x": -153.5,
"y": -2.5, "y": 64.649,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -393,9 +393,9 @@ ...@@ -393,9 +393,9 @@
}, },
"_alignFlags": 9, "_alignFlags": 9,
"_target": null, "_target": null,
"_left": 115, "_left": 115.00000000000006,
"_right": 0, "_right": 0,
"_top": 779, "_top": 711.851,
"_bottom": 0, "_bottom": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -513,8 +513,8 @@ ...@@ -513,8 +513,8 @@
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 114.49999999999994, "x": 114.5,
"y": -2.5, "y": 64.649,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -627,9 +627,9 @@ ...@@ -627,9 +627,9 @@
}, },
"_alignFlags": 9, "_alignFlags": 9,
"_target": null, "_target": null,
"_left": 383, "_left": 383.00000000000006,
"_right": 0, "_right": 0,
"_top": 779, "_top": 711.851,
"_bottom": 0, "_bottom": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -748,7 +748,7 @@ ...@@ -748,7 +748,7 @@
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": -270, "y": -202.851,
"z": 0 "z": 0
}, },
"_lrot": { "_lrot": {
...@@ -919,7 +919,7 @@ ...@@ -919,7 +919,7 @@
"_target": null, "_target": null,
"_left": 335, "_left": 335,
"_right": 0, "_right": 0,
"_top": 1042, "_top": 974.851,
"_bottom": 0, "_bottom": 0,
"_horizontalCenter": 0, "_horizontalCenter": 0,
"_verticalCenter": 0, "_verticalCenter": 0,
...@@ -1029,7 +1029,8 @@ ...@@ -1029,7 +1029,8 @@
"__id__": 45 "__id__": 45
}, },
"closeBtn": null, "closeBtn": null,
"spNode": null, "yes": null,
"no": null,
"_id": "" "_id": ""
}, },
{ {
......
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