Playing Music

For questions about using Classic.

Post » Mon Mar 26, 2012 1:09 am

In my game, I'd like to play music in my layouts in the simplest ways possible. I find that when you load the file during play time as an action, it's a bit complicated for my liking. You have to load the file from where the construct file is, otherwise you have to specify the folder, which I'm guessing as an exe would be a huge pain since I'd have to include all those files with the exe (Or am I wrong?), so I want to avoid that.

I notice that there is a folder for music and sounds in the project bar of Construct, so I'm wondering, how would I play music from the files I already loaded to those folders? I figure just putting them in the program like I would, say, a sprite, would be by far the easiest route to go, but in both Xaudio2 and Audiere, I can't figure out how to play those files I had already loaded.

So basically, what I'm hoping to do is just play the sounds I've already loaded into Construct. Any ideas how I'd go about doing that? Thanks.
B
16
S
2
G
1
Posts: 156
Reputation: 2,112

Post » Mon Mar 26, 2012 5:38 am

Wondering this also.
B
4
S
1
Posts: 13
Reputation: 476

Post » Mon Mar 26, 2012 4:36 pm

Instead of using the "Music" and "Sounds" folders use the "Files" folder. Then use the various "...from resource" actions of XAudio2 to control them. For example, when using "Autoplay resource" you will select the music to play from a list.
As long as you are working on the cap, all those files will stay where they are, just a path to the file is stored. As soon as you build the executable, those files will be copied and added as resources to the .exe-file.
tulamide2012-03-26 16:36:26
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Mar 26, 2012 9:51 pm

What you say seems to be working for me, though only for Audiere, the sounds won't play using Xaudio2 for some reason. On the flip side, Audiere apparently doesn't recognize when it's supposed to be global even though the option is there... oh well, at least sound related things are nice and simple to add in now.

Thanks for the help, tulamide! :)
B
16
S
2
G
1
Posts: 156
Reputation: 2,112

Post » Wed Mar 28, 2012 1:19 pm

Now I can't get the music to stop. The only thing that is working is pause music. I want the music to stop at the end of the layout not just pause or are they one and the same?

I am trying to create an audio event sheet but I don't know how to set it up to change the music when on a specific layout yet.
B
4
S
1
Posts: 13
Reputation: 476

Post » Wed Mar 28, 2012 9:34 pm

In whatever event I use to switch layouts, I also include an action to stop the music within that event. Have you already tried that? It works for me.

B
16
S
2
G
1
Posts: 156
Reputation: 2,112

Post » Thu Mar 29, 2012 8:50 pm

If you have an extra event sheet for all your audio events, you can specify where these events are valid by adding the system expression "get layout name" or "get layout number". You best use it in a compare event, like so:

+ System: LayoutName Equal to "options"
-> add all events as subevents here, that belong to the layout "options"
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest