How do I make a functional radio in game?

Get help using Construct 2

Post » Fri Apr 21, 2017 10:53 pm

Hello everyone! working on a game and had a slight roadblock, Im working on having a functional radio in game that plays a certain group of music files depending on the station, as well as have them play in a random order. The only problem is that I cant seem to get it all evented correctly. any help will be much appreciated!
B
19
S
5
G
1
Posts: 29
Reputation: 1,741

Post » Sat Apr 22, 2017 3:30 pm

Still not having any luck.
B
19
S
5
G
1
Posts: 29
Reputation: 1,741

Post » Sat Apr 22, 2017 6:59 pm

I'd like to help but I'm not entirely sure what you mean either. You can play music files by name, so if you're just trying to have it play random music files, you could use the Play (by name) audio action with the choose() expression and just put all your music file names in there. Then just have that same action for when the track finishes playing.
B
25
S
11
G
3
Posts: 25
Reputation: 3,377

Post » Thu Apr 27, 2017 7:11 am

For some reason I cant seem to get the next song to play when the one finishes. it will play the first song, random song, and when it is done its just silence, no music ever plays after. im using choose() and using the 'On Finished' but still no dice.
My exact setup is

On start of layout > Play Choose("e1","e2","e3","e4")
On "e1" Finished > Play choose("e1","e2","e3","e4")
On "e2" Finished > Play choose("e1","e2","e3","e4")
On "e3" Finished > Play choose("e1","e2","e3","e4")
On "e4" Finished > Play choose("e1","e2","e3","e4")
B
19
S
5
G
1
Posts: 29
Reputation: 1,741

Post » Thu Apr 27, 2017 11:17 am

@FTGamingco

The Audio: On Ended condition uses the Tag you set when you play the music, not the filename.

If you set the same Tag, you will only need one On Ended condition


Also, here's how I would set up an in-game radio with stations:

Global Variable: RadioStation = "none"

Name your music:
Rock1, Rock2, Rock3, Rock4
Pop1, Pop2, Pop3, Pop4
Metal1, Metal2, Metal3, Metal4

Add Audio and Function objects

Code: Select all
On start of layout
   -> Function: Call "OnChangeStation" (choose("Rock","Pop","Metal"))

Audio: On RadioStation Ended
   -> Play RadioStation & choose(1,2,3,4), Tag = RadioStation

Function: OnChangeStation
Function.Param(0) != RadioStation
   -> Audio: Stop RadioStation
   -> Set RadioStation to Function.Param(0)
   -> Play RadioStation & choose(1,2,3,4), Tag = RadioStation


EDIT: Actually, here's a quick example I whipped up: capx (r244)
Music courtesy of Eric Matyas at soundimage.org

EDIT 2: Ok, now I've turned it into a tutorial https://www.scirra.com/tutorials/9483/i ... user-input
Vote for all the Construct 2 games on Steam Greenlight - Find them here
B
32
S
9
G
7
Posts: 444
Reputation: 6,731

Post » Thu Apr 27, 2017 4:16 pm

Ha! It works beautifully! Thank you very much.
B
19
S
5
G
1
Posts: 29
Reputation: 1,741


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Syazanie Amirin and 10 guests