logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
papamk  
#1 Posted : Thursday, August 23, 2018 1:09:11 PM(UTC)
papamk

Rank: Newbie

Groups: Registered
Joined: 8/23/2018(UTC)
Posts: 0
Indonesia
Location: jakarta

Hii

I'm creating an adventure game that will have a couple different play packs / versions / worlds using MelonJS 5.1.

Each pack will have the same baseline overworld music loop, but I'd like to layer on other tracks at the same time. The idea being to add a bit of flare distinction to separate play packs while saving costs on reproducing the same baseline track with subtle differences.

The MelonJS Audio API seems basic: https://melonjs.github.io/melonJS/docs/me.audio.html

Is it possible to be a bit technical with overlaying tracks/fade in/fade out?



If not possible through MelonJS engine, do you have other recommendations via Chrome API / web browser APIs to achieve this?
admin  
#2 Posted : Thursday, August 23, 2018 4:01:25 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 8/7/2018(UTC)
Posts: 1

Actually even though the API looks simple, you can do a lot with it.



first of all, every time you call the play method, it will create a new instance of the given audio asset if required (e..g. already playing), and the method does return a unique instance ID. Once you have that instance id, you will notice that all other methods are taking an optional instance id parameters, so that you can either apply the "method" to the whole group of just a specific instance id.



Not sure if I am clear, but basically it allows you to do something like that :

Code:
// start "inGameMusic"
var id1 = me.audio.play("inGameMusic"); // will return 1 as an example

// start a second instance of "inGameMusic"
var id2 = me.audio.play("inGameMusic"); // will return 2 assuming that this second call was made before "inGameMusic" ended up playing (as a result of the first call).

// see the second instance of "inGameMusic"
me.audio.seek("inGameMusic", 1000, id2);

// speed down and fade first instance
me.audio.rate("inGameMusic", 0.5, id1);
me.audio.fade("inGameMusic", 0, 1.0, 1000, id1);
Is an exciting and highly creative company focusing around delivering games and services for the mobile and web platforms.

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.