Thanh điều chỉnh âm lượng (volume bar) cho Krpano, kết hợp cùng hệ thống âm thanh bạn đã có trước đó:


✅ TÍNH NĂNG MỚI:

  1. Thanh kéo điều chỉnh âm lượng (0–100%)

  2. ✅ Cập nhật trực tiếp âm lượng khi kéo

  3. ✅ Tương thích với hệ thống playsound(...)

  4. ✅ Tự động áp dụng cho mọi scene có âm thanh


🧩 CẤU TRÚC BỔ SUNG

1. 📦 Biến lưu giá trị âm lượng

<var name="sound_volume" value="1.0" />

2. 🎚️ Layer thanh âm lượng

<layer name=”volume_slider_bg”
type=”container”
width=”100″
height=”10″
bgcolor=”0x888888″
align=”righttop”
x=”200″ y=”30″
onclick=”set_volume_by_pos(mouse.x);” /><layer name=”volume_slider_fill”
width=”100″
height=”10″
bgcolor=”0x00ff00″
align=”righttop”
x=”200″ y=”30″
maskchildren=”true” />



3. 🔁 Action xử lý kéo/thay đổi âm lượng

<action name=”set_volume_by_pos”>
calc(volume_ratio, mouse.x / layer[volume_slider_bg].width);
clamp(volume_ratio, 0, 1);
set(sound_volume, volume_ratio);
set(layer[volume_slider_fill].width, volume_ratio * 100);
updatesoundvolume();
</action><action name=”updatesoundvolume”>
if(!sound_muted, setsoundvolume(bg, sound_volume); );
</action>



4. 🎵 Cập nhật trong các hàm playsound từng scene:

Ví dụ scene 1:

<action name="playscene1_audio">
stopsound(bg);
if(!sound_muted,
playsound(bg, "sounds/scene1.mp3");
setsoundvolume(bg, sound_volume);
);
set(global.scene_audio, 'scene1');
</action>

Tương tự thêm setsoundvolume(...) vào các playscene2_audio, playscene3_audio


5. 🎨 Gợi ý cải tiến UI:


📌 Tóm lại:

 


Xem thêm: 

  1. Mua bản quyền krpano – Buy Licenses
  2. Krpano Plugins
  3. Khóa học VR360