00:00
00:00
Newgrounds Background Image Theme

PopiSlim just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Idea behind controlling sound?

677 Views | 6 Replies
New Topic Respond to this Topic

Idea behind controlling sound? 2014-08-07 01:54:21


I've been pondering how it would be best to handle all of the sounds in my game. For now, let's assume I'm grouping all sounds together, so there won't be a distinction between sound effects and background music. Also, let's assume all I want to be able to do is switch between audible and mute.

I figure I can create a custom class called Music.as or something and just tie all of my sounds to it. Sound files in the Library can have base classes, right? Haven't checked yet.

If that is the case I think I could easily toggle the sounds/music that are playing as well as any sounds that are about to be played. I noticed that after looking at this there doesn't seem to be a mute property tied to any sound transform. I guess that's not an issue as I can just toggle volume, but I still find it weird.

Does any of this make sense? Any ideas about a better approach? This is my first time actually using sounds dynamically. Want to do it right.

I was actually hoping to be able to toggle volume with the mouse scroll wheel, but that definitely isn't going to happen for obvious reasons.

Response to Idea behind controlling sound? 2014-08-07 02:16:35


Here's a sample of my Sm.hx (sound manager) it's in Haxe but most of it will still make sense.

To add in mute I'd just have a mute() function that would look something like this:

public static function mute():Void
{
mutted = !mutted;

if (mutted)
{
_musicChannel.stop();
} else{
playMusic();
}
}

I was actually hoping to be able to toggle volume with the mouse scroll wheel, but that definitely isn't going to happen for obvious reasons.

Why not?


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

Response to Idea behind controlling sound? 2014-08-07 02:17:37


Sorry, I didn't realize you'd have to download that. Here's in pastebin. http://pastebin.com/VA9zYkbG


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

Response to Idea behind controlling sound? 2014-08-07 08:39:02


At 8/7/14 02:16 AM, MintPaw wrote: Here's a sample of my Sm.hx (sound manager) it's in Haxe but most of it will still make sense.

To add in mute I'd just have a mute() function that would look something like this:

public static function mute():Void
{
mutted = !mutted;

if (mutted)
{
_musicChannel.stop();
} else{
playMusic();
}
}

I'll check out the pastbin link you sent me when I get home from school. Chances are I'll wind up making a much more retarded version of sound control. I see your "Assets.getSound...". Looks like that's what i was considering before. I assume you're using that class for more than just music, right?

See, this is why being on a Mac sucks for me because I don't get to use FlashDevelop. I know there is no timeline on it, so it would force me to learn putting images together using code. that probably sounded really ignorant, but that is my current understanding.

I've never seen Haxe before. it almost looks like CSS to me. Looks like you're also able to code for both mobile and desktop platforms. So, what, are you making a single game that changes functionality depending on if you're on a phone or a desktop?

I was actually hoping to be able to toggle volume with the mouse scroll wheel, but that definitely isn't going to happen for obvious reasons.
Why not?

As far as I've tried, trying to scroll just moves the page. Even if it would've be able to do what I'd wanted, the page moving is undesirable. Maybe things work differently from the dumping grounds, though.

Response to Idea behind controlling sound? 2014-08-07 08:51:59


At 8/7/14 08:39 AM, Barzona wrote: I'll check out the pastbin link you sent me when I get home from school. Chances are I'll wind up making a much more retarded version of sound control. I see your "Assets.getSound...". Looks like that's what i was considering before. I assume you're using that class for more than just music, right?

That's a Haxe class and method, which allows you to get resources for your game depending on the kind of file it is.

See, this is why being on a Mac sucks for me because I don't get to use FlashDevelop. I know there is no timeline on it, so it would force me to learn putting images together using code. that probably sounded really ignorant, but that is my current understanding.

You don't need FlashDevelop. I'm sure there a few Mac users here who have a workflow setup that doesn't use the Flash IDE. A quick google turns up FDT, an Eclipse plugin for Haxe and presumably AS3.

I've never seen Haxe before. it almost looks like CSS to me. Looks like you're also able to code for both mobile and desktop platforms. So, what, are you making a single game that changes functionality depending on if you're on a phone or a desktop?

It should look almost identical to AS3, it shares very little in common with CSS.

As far as I've tried, trying to scroll just moves the page. Even if it would've be able to do what I'd wanted, the page moving is undesirable. Maybe things work differently from the dumping grounds, though.

If the Flash object has focus, I think it catches the mouse scroll - although I'm not 100% sure.

Response to Idea behind controlling sound? 2014-08-07 11:34:19


Browsers and OSs handle flash mouse scroll differently, locking the mouse to the flash player will never be consistent across them so don't use it. Maybe in an air app or popout flash player, but definitely not in browsers.

Mac noobs use sublime for as3.

Response to Idea behind controlling sound? 2014-08-07 13:19:22


You could always dualboot or use sublime text, or hell even just use notepad++. You should get used to pure AS3 though.

And sorry, I didn't realize how much of that was Haxe and not going to make any sense. You could probably the same thing but embed all the mp3s into class variables and just call them by using Sm.playEffect(#) using constants ans numbers to find the correct sound.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature