tags: sound title: Panning brief: This example demonstrates how to pan a sound effect according to a GO's(game object) position on the screen. author: FlexYourBrain
Overview : A coin bounces around the screen and on collision detection we get the coins x position then normalize that value for use in the sound components pan property. As the API states "The pan on the sound-component. The valid range is from -1.0 to 1.0, representing -45 degrees left, to +45 degrees right." we can use this information along with our x value from our coin object and normalize it into the correct range.
The setup consists of a coin game object, three stone objects and walls for collision.
Coin : contains:
DYNAMIC
and a Sphere Shape.Stones : contains:
STATIC
and 1 box Shape to match the sprite image.Walls : contains:
STATIC
and 4 box Shapes that make up the walls along the bounds of the game screen.