Playing Sounds and Music through Expressions
Hello, everyone!
I'm currently developing a game that reads through a spreadsheet to determine images. I had hoped to also tie certain sounds to those images, depending on what row the game's currently on. For example, on row 18, the game would display "img-smiley-face.png" and play the sound "sfx-buzz.mp3".
However, I realize there may not be an option to do that the same way you can change the Image attribute via a Change Attribute behavior, i.e. changing an actor's self.Image attribute to tableCellValue(table,row,column).
Does anyone know if there's a way to do this currently?
The only way I can figure to do it now is use a Rule, so that it says when game.Row = 18, play Sound "sfx-buzz.mp3"...but I'd like to avoid that since there are over 2000 lines that would need sound.
Any help or direction would be greatly appreciated!
Comments
I'm afraid the you only way to currently play sounds and music in GS is with the traditional Play Behaviors.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
I was afraid of that. :(
I might go through the trouble of getting all 2000+ lines in individually using Rules to see how much it impacts the app size.
This remains my most wanted new GS feature.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
For anyone who may find this thread, I ran a quick test with 20 sound FX files. All of them were under 1 second each. I set up a rule per SFX file such that:
if tableCellValue(myTable, currentRow, sfxColumn) is "play_buzz_sound" then play sound_buzz.mp3
I did this for 20 files and ended up adding 1mb to the total app size.
It also took me ~1 hour just to do this, though...which included the initial set-up, then a little debugging to get it all working correctly.
I can't imagine doing this for 2000+ lines, though. I just thought about having to debug all of that...and decided it was best not to put so much effort into something that may end up not really impacting the overall game.
In cases like this, I definitely think it'd be useful to be able to play a sound via a text expression.