Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in FlxSound.proximity #101

Merged
merged 2 commits into from Sep 21, 2012
Merged

Conversation

Dovyski
Copy link
Member

@Dovyski Dovyski commented Sep 18, 2012

FlxSound.proximity was inverted: the closer the object was, the lower was the volume.
Fix #4, AdamAtomic#228 .

FlxSound.proximity was inverted: the closer the object was, the lower was the volume.
Fix FlixelCommunity#4, AdamAtomic#228 .
@moly
Copy link
Member

moly commented Sep 18, 2012

I think var d:Number = (_target.x-x)/_radius; should be swapped to var d:Number = (x-_target.x)/_radius;. If the target object is to the left of you the sound should be coming from the left speaker.

@Dovyski
Copy link
Member Author

Dovyski commented Sep 18, 2012

Ok, I will fix that.

@Dovyski
Copy link
Member Author

Dovyski commented Sep 18, 2012

I've tested the code and the original version _target.x - x works the way you described. If the target object is to the left of you, then the result is negative, what produces left-panning.

According to the SoundTransform docs, the pan property is:

The left-to-right panning of the sound, ranging from -1 (full pan left) to 1 (full pan right).
A value of 0 represents no panning (balanced center between right and left).

@moly
Copy link
Member

moly commented Sep 19, 2012

Sorry, I meant to say that if the FlxSound is to the left of the target object, the sound should becoming from the left speaker.

@Dovyski
Copy link
Member Author

Dovyski commented Sep 20, 2012

I was just wondering if the sound source is to the left of the target, the target will hear the sound source using its right ear, isn't it? This is the current behavior of FlxSound.

Do you disagree about that, @moly ?

@moly
Copy link
Member

moly commented Sep 20, 2012

Here's how I picture it:
Mario

Imagine that Mario is the target, and that the Goomba is producing a sound. In this 2D world the Goomba is behind Mario and shown on the left side of the screen, so you would expect the sound to come from behind him on the left side speaker.

@Dovyski
Copy link
Member Author

Dovyski commented Sep 20, 2012

Ok, now I got it! :) I couldn't agree more. I will change that line according to your suggestion.

If FlxSound is to the left of the target object, the sound comes from the left speaker.
@IQAndreas
Copy link
Member

var d:Number = (x-_target.x)/_radius;

Sorry, correct me if I'm wrong, but the way you had it was right, correct?

If we use the above example, the location of Mario would be x=100 and the location of the goomba _target.x=20. This means 100-20=80, positive, so the sound would be coming out of the right speaker.

@moly
Copy link
Member

moly commented Sep 21, 2012

In the above example Mario is the _target, and the Goomba would be x and y. The Goomba is emitting the sound.

@IQAndreas
Copy link
Member

In the above example Mario is the _target, and the Goomba would be x and y. The Goomba is emitting the sound.

(from `FlxSound) The X position of this sound in world coordinates.

Ah, yes, I see now. Perfect, then I'll go ahead and merge this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants