Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - NewZombieland

Pages: [1]
1
Audio / Re: Audio Issue
« on: August 02, 2012, 11:25:51 pm »
No console errors, though when I call the sounds getStatus() it returns 2 (Sound::Playing).
It just dosen't play.
here's the hedder for the class:

#ifndef PLAYSOUNDEVENT_H_
#define PLAYSOUNDEVENT_H_


#include <SFML/Audio.hpp>

#include "Event.h"
class PlaySoundEvent: public Event
{
    sf::SoundBuffer sound;
public:
        PlaySoundEvent(sf::SoundBuffer sound);
        virtual ~PlaySoundEvent();
        void fire();
};

#endif /* PLAYSOUNDEVENT_H_ */

Cheers

2
Audio / Audio Issue
« on: August 02, 2012, 01:32:49 am »
Hello, I'm attempthing to put audio into my SFML 2.0 game and have hit a bit of a road-block.
I can play audio fine my my games main function with this code:
sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("sound file name"))
    {
        std::cout<<"failed to load sound"<<std::endl;
    }
   
    sf::Sound sound(buffer);
    sound.play();

but I want another class, PlaySoundEvent to be able to trigger sounds, but this just dosent work.

PlaySoundEvent is a fairly simple class, you pass it a buffer and then call the fire(), witch just creates a sf::Sound with the supplied buffer and then plays it.

so the code:

sf::SoundBuffer buffer;
    if (!buffer.loadFromFile("sound file name"))
    {
        std::cout<<"failed to load sound"<<std::endl;
    }
   
    PlaySoundEvent sndEvent(buffer);
    sndEvent.fire();

should work exactly the same as above, but it dosen't.
Have I massed up my includes?

PlaySoundEvent .fire() looks like this:
void PlaySoundEvent::fire()
{
    sf::Sound soundObj(sound);
    soundObj.setVolume(100);
    soundObj.play();
}

Pages: [1]
anything