Commit f0372884 authored by haiyoucuv's avatar haiyoucuv

上传

parent 6b5fa173
...@@ -6,38 +6,62 @@ const {ccclass, property} = _decorator; ...@@ -6,38 +6,62 @@ const {ccclass, property} = _decorator;
@ccclass('MusicBtn') @ccclass('MusicBtn')
export class MusicBtn extends Component { export class MusicBtn extends Component {
@property(SpriteFrame) closeSf: SpriteFrame = null;
@property(SpriteFrame) openSf: SpriteFrame = null;
sp: Sprite = null; static btnList: MusicBtn[] = [];
private _open: boolean = false; private static _open: boolean = true;
set open(open: boolean) { static set open(open: boolean) {
this._open = open; this._open = open;
this.sp.spriteFrame = open ? this.openSf : this.closeSf;
for (const btn of this.btnList) {
btn.open = open;
}
if (open) { if (open) {
AudioMgr.ins.resume(); AudioMgr.ins.resume();
AudioMgr.ins.musicVolume = 1;
AudioMgr.ins.soundVolume = 1;
} else { } else {
AudioMgr.ins.pause(); AudioMgr.ins.stop();
AudioMgr.ins.musicVolume = 0;
AudioMgr.ins.soundVolume = 0;
} }
} }
static get open() {
return this._open;
}
@property(SpriteFrame) closeSf: SpriteFrame = null;
@property(SpriteFrame) openSf: SpriteFrame = null;
sp: Sprite = null;
private _open: boolean = true;
set open(open: boolean) {
this._open = open;
this.sp.spriteFrame = open ? this.openSf : this.closeSf;
}
get open() { get open() {
return this._open; return this._open;
} }
onLoad() { onLoad() {
this.sp = this.getComponent(Sprite); this.sp = this.getComponent(Sprite);
MusicBtn.btnList.push(this);
MusicBtn.open = MusicBtn.open;
this.node.on(Button.EventType.CLICK, this.clickNode, this); this.node.on(Button.EventType.CLICK, this.clickNode, this);
} }
start() { protected onDestroy() {
this.open = true; MusicBtn.btnList.splice(MusicBtn.btnList.indexOf(this), 1);
} }
clickNode() { clickNode() {
this.open = !this.open; MusicBtn.open = !MusicBtn.open;
} }
} }
......
import { _decorator, assetManager, game, Component, Label, Node, Prefab, profiler, ProgressBar, resources, } from 'cc'; import {
_decorator,
assetManager,
game,
Component,
Label,
Node,
Prefab,
profiler,
ProgressBar,
resources,
input, Input,
} from 'cc';
import { PREVIEW } from 'cc/env'; import { PREVIEW } from 'cc/env';
import { UIMgr } from "../Module/UIMgr"; import { UIMgr } from "../Module/UIMgr";
import { changeScene, showToast } from "db://assets/Module/UIFast"; import { changeScene, showToast } from "db://assets/Module/UIFast";
...@@ -7,6 +19,7 @@ import { sendWebNet, WebNetName } from "../Scripts/Utils/WebNet/WebNet"; ...@@ -7,6 +19,7 @@ import { sendWebNet, WebNetName } from "../Scripts/Utils/WebNet/WebNet";
import { getUrlParams } from "../Scripts/Utils/WebNet/web/webTools"; import { getUrlParams } from "../Scripts/Utils/WebNet/web/webTools";
import store from "../Scripts/store/store"; import store from "../Scripts/store/store";
import { AudioMgr } from "../core_tgx/base/AudioMgr"; import { AudioMgr } from "../core_tgx/base/AudioMgr";
import { MusicBtn } from "../Component/MusicBtn/MusicBtn";
const {ccclass, property} = _decorator; const {ccclass, property} = _decorator;
...@@ -40,6 +53,8 @@ export class Start extends Component { ...@@ -40,6 +53,8 @@ export class Start extends Component {
document.body.style.visibility = "visible"; document.body.style.visibility = "visible";
MusicBtn.open = false;
} }
onDestroy() { onDestroy() {
......
...@@ -39,6 +39,13 @@ export class AudioMgr { ...@@ -39,6 +39,13 @@ export class AudioMgr {
//@en add AudioSource componrnt to play audios. //@en add AudioSource componrnt to play audios.
//@zh 添加 AudioSource 组件,用于播放音频。 //@zh 添加 AudioSource 组件,用于播放音频。
this._audioSource = audioMgr.addComponent(AudioSource); this._audioSource = audioMgr.addComponent(AudioSource);
this._audioSource.onEnable = () => {
}
this._audioSource.onDisable = () => {
}
} }
public get audioSource() { public get audioSource() {
...@@ -62,7 +69,7 @@ export class AudioMgr { ...@@ -62,7 +69,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, bundleName: string = 'resources') { playOneShot(sound: AudioClip | string, volume: number = this._soundVolume, 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);
......
...@@ -1102,9 +1102,9 @@ ...@@ -1102,9 +1102,9 @@
"_dstBlendFactor": 4, "_dstBlendFactor": 4,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 209,
"g": 255, "g": 235,
"b": 255, "b": 251,
"a": 255 "a": 255
}, },
"_string": "Better luck next time", "_string": "Better luck next time",
...@@ -1770,9 +1770,9 @@ ...@@ -1770,9 +1770,9 @@
"_dstBlendFactor": 4, "_dstBlendFactor": 4,
"_color": { "_color": {
"__type__": "cc.Color", "__type__": "cc.Color",
"r": 255, "r": 209,
"g": 255, "g": 235,
"b": 255, "b": 251,
"a": 255 "a": 255
}, },
"_string": "System exception.\nYou can check the coupon pack later\nto see i", "_string": "System exception.\nYou can check the coupon pack later\nto see i",
......
...@@ -47,19 +47,22 @@ ...@@ -47,19 +47,22 @@
}, },
{ {
"__id__": 86 "__id__": 86
},
{
"__id__": 96
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 96 "__id__": 102
}, },
{ {
"__id__": 98 "__id__": 104
} }
], ],
"_prefab": { "_prefab": {
"__id__": 100 "__id__": 106
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
...@@ -2277,6 +2280,165 @@ ...@@ -2277,6 +2280,165 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{
"__type__": "cc.Node",
"_name": "You won",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 97
},
{
"__id__": 99
}
],
"_prefab": {
"__id__": 101
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 215.481,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 96
},
"_enabled": true,
"__prefab": {
"__id__": 98
},
"_contentSize": {
"__type__": "cc.Size",
"width": 103.16465759277344,
"height": 34.208999999999996
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "4e2gFneM5CWYVJO2N2fmIM"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 96
},
"_enabled": true,
"__prefab": {
"__id__": 100
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 209,
"g": 235,
"b": 251,
"a": 255
},
"_string": "You won",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 27.15,
"_fontSize": 27.15,
"_fontFamily": "Arial",
"_lineHeight": 27.15,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_enableOutline": false,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
},
"_shadowBlur": 2,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "5axHmdStBDI6pn/83bDDV4"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "fdW/UroghGbrwd6gAK82SM",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
...@@ -2287,7 +2449,7 @@ ...@@ -2287,7 +2449,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 97 "__id__": 103
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
...@@ -2315,7 +2477,7 @@ ...@@ -2315,7 +2477,7 @@
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 99 "__id__": 105
}, },
"closeBtn": { "closeBtn": {
"__id__": 86 "__id__": 86
......
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