Example #1
0
	Textbox::Textbox(std::map<std::string, sf::Sprite>& faceMap, const sf::Font& font, sf::Sound& bleep, int width_box, int height_box, bool block, int font_size, int padding) :
		faceMap(faceMap), width(width_box), height(height_box), bleep(bleep), block_draw(block), padding(padding) {
		
		displayText.setFont(font);
		displayText.setCharacterSize(font_size);
		displayText.setColor(sf::Color::White);
		
		bleep.setPitch(2);
		if (!block_draw)
		{
			faceSprite.setTextureRect(sf::IntRect(0, 0, faceSprite.getLocalBounds().width, faceSprite.getLocalBounds().height));
			faceSprite.setOrigin(faceSprite.getLocalBounds().width*.5, faceSprite.getLocalBounds().height*.5);
			faceSprite2.setTextureRect(sf::IntRect(0, 0, faceSprite2.getLocalBounds().width, faceSprite2.getLocalBounds().height));
			faceSprite2.setOrigin(faceSprite2.getLocalBounds().width*.5, faceSprite2.getLocalBounds().height*.5);
			rectText.setSize(sf::Vector2f(width - padding, height*.3));
			rectText.setOrigin((width - padding)*.5, height*.5);
			rectText.setFillColor(sf::Color::Black);
			rectText.setOutlineColor(sf::Color::White);
			rectText.setOutlineThickness(2);
			actorName.setColor(sf::Color::Yellow);
			actorName.setFont(font);
		}
		else {
			rectText.setSize(sf::Vector2f(width, height));
			rectText.setOrigin(width*.5, height*.5);
		}	
	}
 void play_sound(sf::Sound& sound, const SoundSample& sample, const PlaybackProperties& properties, bool looped)
 {
   sound.setBuffer(sample);
   sound.setPitch(properties.pitch);
   sound.setAttenuation(properties.attenuation);
   sound.setLoop(looped);
   sound.setRelativeToListener(properties.relative_to_listener);
   sound.setMinDistance(properties.min_distance);
   sound.setVolume(properties.volume * 100.0f);
   sound.play();
 }