0 Favourites

How do I make a functional radio in game?

  • 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!

  • Still not having any luck.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • 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.

  • 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")

  • 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

    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
    [/code:3bsz5vfu]
    
    [b]EDIT:[/b] Actually, here's a quick example I whipped up: [url=https://www.dropbox.com/s/r7a2nfgxqaqah3h/Radio%20Stations.capx?dl=0]capx (r244)[/url]
    Music courtesy of [url=http://soundimage.org/]Eric Matyas at soundimage.org[/url]
    
    [b]EDIT 2:[/b] Ok, now I've turned it into a tutorial
  • Ha! It works beautifully! Thank you very much.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)