
SFML Game Development By Example
By :

In order to make our entities emit sounds, some preparations have to be made. For now, we're only going to concern ourselves with simply adding the sound of footsteps whenever a character walks. Doing so requires a slight modification of the EntityMessage
enumeration in EntityMessages.h
:
enum class EntityMessage{ Move, Is_Moving, Frame_Change, State_Changed, Direction_Changed, Switch_State, Attack_Action, Dead };
The highlighted bits are what we're going to be focusing on. Frame_Change
is a new type of message that's been added in this chapter, and Direction_Changed
will be used to manipulate the sound listener's direction. In order to detect when a frame changes during the animation process, however, we're going to need to make a few more adjustments to our code base.
In order to have the ability to send out the Frame_Change
message we've just created, our animation system is going to need a few minor additions...
Change the font size
Change margin width
Change background colour