That totally works!
Thank you very much all for your help!
Thank you very much all for your help!







This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuote from: Crimson Wizard on Wed 24/02/2021 15:10:53
This code takes the channel that engine chose, and stores its pointer in your variable. It's engine that puts music to *some* channel which it decided to, and then tells you what it is.
If this is what you expect to have, then it's working properly of course.
AudioChannel *bgm;
AudioChannel *bgm2;
}
Quote from: Crimson Wizard on Wed 24/02/2021 14:55:49
I was suspecting you may be planning something like this, this is a common mistake. In AGS currently you cannot tell which channel to play clip on, AGS chooses one automatically and then Play returns which one was chosen.
If you reserve only 1 channel for music this is where it will play all the time, if you have more reserved it will take free one or replace a clip if new one has higher priority.
What you can do though is to assign resulting channel to your variables, this way you will at least know where the clips are playing and still may control their volume etc.
EDIT: Or maybe I misunderstood and this is actually what you are doing? ...
AudioChannel *bgm;
void SetBGM.Play(AudioClip *music) { //Canal secundario de música
if (bgm == null || bgm.PlayingClip != music) {
bgm = music.Play();
}
else if(music == null) {
music.Stop();
}
}
Quote from: Laura Hunt on Wed 24/02/2021 14:38:42Quote from: eri0o on Wed 24/02/2021 11:21:32
AGS does have crossover, if you have a single music channel, you can set it to do crossover everytime a new music is played - it's buried somewhere in sound clip properties.
Just wanted to point out that this is not correct; you actually need two channels (since a crossfade requires both tracks to be playing at the same time). If you only have one music channel, you will not be able to perform a crossfade and what will happen instead is that the first track will fade out and then the next track will fade in.
Quote from: Crimson Wizard on Wed 24/02/2021 13:59:52Ok, I'll try if it works.
In some function, for example you may use game_start for that.
Quote from: Crimson Wizard on Wed 24/02/2021 13:59:52Mmm, ok. So the array is not a solution.
If that's the case, then there's no point in assigning bgm and bgm2 to array at all, as that will just copy "null" values to array.
Quote from: Crimson Wizard on Wed 24/02/2021 13:59:52Ok. What I'm trying to do eith this script is to manage two music channels. So I want in my functions to be able to asign a chanel.
Note that you cannot create audio channel objects yourself. Only engine creates them. These objects are found in System.AudioChannel[] array. System.AudioChannelCount property tells how many are there.
Also, when you call audioclip.Play() that function returns audio channel pointer on which audio clip ended up.
So, when you are using AudioChannel* pointers either you assign your pointers to one of the System.AudioChannel elements, or you assign them to result of Play() function. Depending on what exactly you are trying to do.
struct SetBGM {
import static void Play(AudioClip *music, SetBGM_Channel = 1, int initialvol = 100, SetBGM_FadeIn fadeinmusic = Direct, int time = 0);
import static void SetPosition(SetBGM_Channel = 1, int time);
import static int GetPosition(SetBGM_Channel = 1);
import static void CrossFade(SetBGM_FromTo, int time);
}
Quote from: Crimson Wizard on Wed 24/02/2021 12:24:35
This would be normally a proper code, but where exactly do you put it? For example, if you put this outside of a function that would create error.
AudioChannel *bgm;
AudioChannel *bgm2;
Quote from: Crimson Wizard on Wed 24/02/2021 12:24:35
Also, do you assign bgm and bgm2 to anything before that? If you just declare AudioChannel* pointer that does not create a channel.
Quote from: Crimson Wizard on Wed 24/02/2021 12:24:35
AGS has a fixed number of audio channels that are always created and present. They may be accessed with System.AudioChannels[] array.
Here's an explanation of AGS audio channels that I once wrote, I am linking it to every such discussion just in case:
https://www.adventuregamestudio.co.uk/forums/index.php?topic=54062.msg636546051#msg636546051
Quote from: Khris on Wed 24/02/2021 12:53:31So if I use them as pointers then I don't know how and where can I define them as AudioChannel objects, because I'm not able to define pointers in the enum.
But again, this is pretty pointless, since you can just use a named pointer instead of the array.
Quote from: Khris on Wed 24/02/2021 12:53:31
In the context of a module you would probably want to provide functions that allow the user to conveniently manage background music without worrying about channels at all. The first step to design something like that is to write the code you want to be able to use, like this:Code: ags Room.AddBGM(discoTrack1);
Next you write the functions that provide these commands, while implementing the necessary data structure.
AudioChannel *myChannels[2];
myChannels[0] = bgm;
myChannels[1] = bgm2;
myChannels[0] = *bgm;
myChannels[1] = *bgm2;
enum SetBGM_Channel {
Channel1 = *bgm,
Channel2 = *bgm2,
};
AudioChannel *bgm; //Channel 1
AudioChannel *bgm2; //Channel 2
QuoteAn error ocurred whilst trying to load your game. The error was:
getSpriteAsBitmap32bit: Unable to find sprite 0
If you cannot resolve the error, please post on the AGS Techinical Forum for assistance.
Quote from: Cassiebsg on Fri 15/01/2021 18:19:25Sorry, the links are dead. Do you know any place where the screenshots are available for ever?
Uhm, all I get from your pics is "image not found"
Quote from: eri0o on Thu 14/01/2021 21:37:50Hello.
Hey, you got some cool devstreams recorded in your YouTube, it would be cool to get some updates here when them happen!
By continuing to use this site you agree to the use of cookies. Please visit this page to see exactly how we use these.
Page created in 0.104 seconds with 14 queries.