Game Development Reference
In-Depth Information
Apart from the position, we can also set the orientation of our listener by calling
Listener::setDirection() . This defines the direction which the listener is fa-
cing. If we are talking about a top-down shooter, for example, the main character can ro-
tate 360 degrees. The Listener can handle such behavior with the Listen-
er::setDirection() function. It expects a 3D vector which represents the direction
of the listener. Since this is just a direction, the vector passed should be normalized, but
SFML doesn't require it.
Sticking with our example of the hero sprite, we can calculate the direction vector for the
listener as well:
The preceding example uses the common formula of transforming an angle to a 2D vector
direction by using the cosine and sine values of that angle. It is important to note that the
Search WWH ::

Custom Search