添加全局音效音量 更改按钮音效

This commit is contained in:
Lenheart 2024-12-19 23:55:34 +08:00
parent 948bce5dd9
commit 562c5b6738
4 changed files with 33 additions and 24 deletions

View File

@ -10,7 +10,8 @@ function InitGame() {
// MySocket("127.0.0.1", 19666);
//设定全局默认音量
_Globa_Audio_Volume_ = 0.1;
_Globa_Audio_Volume_ = 0.3;
_Globa_Sound_Volume_ = 0.3;
Script();
@ -21,6 +22,13 @@ function InitGame() {
//初始化鼠标
_IMouse_();
//预加载
Animation("ui/charactercreate/dust.ani");
Animation("ui/charactercreate/firedust.ani");
Animation("ui/charactercreate/dust.ani");
Animation("ui/charactercreate/aura.ani");
//进入下一个场景
TestStage();
}

View File

@ -65,16 +65,18 @@ class _Login_Window extends Yosin_Window {
// print(info);
}
//关闭登录界面
NoticeBox.CloseWindow();
CloseWindow();
NoticeBox.DestroyWindow();
DestroyWindow();
local Window = Sq_CreateWindow(_Select_Character_Window, "选择角色界面窗口", 0, 0, 1066, 600, 0);
Window.Init(PackInfo);
Window.BackGroundMusic = this.BackGroundMusic;
}.bindenv(this));
}
function PlayBackgroundMusic() {
// BackGroundMusic = Sound("SoundPacks/Loop.ogg");
// BackGroundMusic.Play();
BackGroundMusic = Audio(MUSIC.M_CHARACTER_SELECT);
BackGroundMusic.Play();
}
function MusicLogic() {
@ -93,8 +95,10 @@ class _Login_Window extends Yosin_Window {
//登录按钮
local LoginButton = Yosin_BaseButton(770, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
LoginButton.OnClickSound = SOUND.CLICK_BUTTON4;
//点击事件回调
LoginButton.OnClick = function(Button) {
// sqdbg_break();
MySocket.Send(PACKET_ID.LOGIN, {
account = AccountInputBox.str,
password = PasswordInputBox.str
@ -111,6 +115,7 @@ class _Login_Window extends Yosin_Window {
//注册按钮
local RegisterButton = Yosin_BaseButton(865, 410, 77, 24 "sprite/interface/lenheartwindowcommon.img", 90);
RegisterButton.OnClickSound = SOUND.CLICK_BUTTON1;
//点击事件回调
RegisterButton.OnClick = function(Button) {
MySocket.Send(PACKET_ID.REGISTER, {
@ -162,14 +167,12 @@ class _Login_Window extends Yosin_Window {
});
PasswordTextActor.SetPosition(720, 281);
Addchild(PasswordTextActor);
}
//逻辑入口
function Proc(Dt) {
MusicLogic();
if (Visible) MusicLogic();
SyncPos(X, Y);
base.Proc(Dt);
}

View File

@ -98,6 +98,7 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
SettingBackgroundButtonList = [];
SetClipRect(5, 9, gWidth, gHeight - 9);
SetZOrder(1000);
}
function Init() {
@ -109,7 +110,7 @@ class _Select_Character_SettingBackground_Window extends Yosin_Window {
//背景
Background = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/setup/setup.img", 17);
Background.SetPosition(X, Y);
Background.SetZOrder(-10);
// Background.SetZOrder(-10);
Background.SetVisible(false);
//因为裁切原因 所以要添加到父对象中
Parent.Addchild(Background);
@ -215,7 +216,6 @@ class _Select_Character_Chr extends Yosin_CommonUi {
Charc.SetName(Info.lv + "级 " + Info.name);
Charc.AnimationManager.Name.MoveBy(0, 180);
Addchild(Charc);
// print(Charc.AnimationManager.Children.len());
}
function SetIdxPosition(Idx) {
@ -364,14 +364,6 @@ class _Select_Character_Window extends Yosin_Window {
//注册窗口
RegisterWindow();
// OpenDeBug();
//播放音乐
PlayBackgroundMusic();
}
function PlayBackgroundMusic() {
// BackGroundMusic = Sound("SoundPacks/Loop.ogg");
// BackGroundMusic.Play();
}
function MusicLogic() {
@ -387,7 +379,7 @@ class _Select_Character_Window extends Yosin_Window {
//角色对象
for (local i = 0; i< 5; i++) {
//选中框
//角色框背景
local CharBg = CL_SpriteObject("sprite/interface2/selectcharacter_ver2/selectcharacter.img", 4);
CharBg.SetMode(0);
CharBg.SetPosition(184 + (i * 142) + 3, ((i % 2) ? 13 : 0) + 93);
@ -432,7 +424,8 @@ class _Select_Character_Window extends Yosin_Window {
color = sq_RGBA(186, 147, 97, 255)
});
CreateButton.OnClick = function(Button) {
Sq_CreateWindow(_CreateCharacter, "创建角色界面窗口", 0, 0, 1066, 600, 0);
local Window = Sq_CreateWindow(_CreateCharacter, "创建角色界面窗口", 0, 0, 1066, 600, 0);
Window.ResetFocus();
}.bindenv(this);
AddUIChild(CreateButton);
CreateTextActor.SetPosition(6, 5);
@ -488,7 +481,12 @@ class _Select_Character_Window extends Yosin_Window {
local StartButton = Yosin_BaseButton(475, 546, 118, 47 "sprite/interface2/selectcharacter/selectcharacter.img", 7);
//点击事件回调
StartButton.OnClick = function(Button) {
print(CurrentSelectCharacterIdx);
//停止背景音乐
if (BackGroundMusic) {
BackGroundMusic.Pause();
}
SetVisible(false);
//TODO 发送进入游戏请求
}.bindenv(this);
AddUIChild(StartButton);
}
@ -531,7 +529,7 @@ class _Select_Character_Window extends Yosin_Window {
//逻辑入口
function Proc(Dt) {
MusicLogic();
if (Visible) MusicLogic();
SyncPos(X, Y);
base.Proc(Dt);

View File

@ -86,7 +86,7 @@ class _Yosin_MessageBox extends Yosin_Window {
local confirmButton = Yosin_BaseButton(cacheW / 2 - 28, cacheH - 15, 56, 24 "sprite/interface/lenheartwindowcommon.img", 12);
confirmButton.OnClick = function(Button) {
//关闭本窗口
CloseWindow();
DestroyWindow();
}.bindenv(this);
AddUIChild(confirmButton);
@ -99,7 +99,7 @@ class _Yosin_MessageBox extends Yosin_Window {
local closeButton = Yosin_BaseButton(cacheW - 15, 5, 10, 9 "sprite/interface/lenheartwindowcommon.img", 42);
closeButton.OnClick = function(Button) {
//关闭本窗口
CloseWindow();
DestroyWindow();
}.bindenv(this);
AddUIChild(closeButton);