本文整理汇总了C++中sf::Sound::setVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::setVolume方法的具体用法?C++ Sound::setVolume怎么用?C++ Sound::setVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sound
的用法示例。
在下文中一共展示了Sound::setVolume方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
sf::Sound * SoundsManager::createMusic(sf::Uint8 ID)
{
music.setBuffer(buffers[ID]);
music.setVolume(buffers[ID].defaultVolume * static_cast<float>(musicVolume) / 100.f);
return &music;
}
示例2: play_sound
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();
}
示例3: Entity
Entity(sf::Texture& sTexture, EntityType type, Collidable::Type colType, sf::SoundBuffer& soundBuf1, sf::SoundBuffer& soundBuf2)
: Collidable(colType)
, mSprite(sTexture)
, mDeathSound(soundBuf1)
, mLaserSound(soundBuf2)
, mType(type)
, mCollected(0)
, mFireProjectile(false)
, mFireCountdown(sf::Time::Zero)
{
sf::FloatRect bounds = mSprite.getLocalBounds();
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
switch(type)
{
case EntityType::Player: mHitPoints = PlayerHitPoints; break;
case EntityType::Enemy: mHitPoints = EnemyHitPoints; break;
default: break;
}
mLaserSound.setVolume(75.f);
mDeathSound.setVolume(75.f);
};
示例4: main
// Program entry point
int main(int argc, char ** argv) {
titleImg.loadFromFile("assets/title.png");
sf::SoundBuffer sb;
sb.loadFromFile("assets/avalanche.ogg");
boulderSound.setBuffer(sb);
boulderSound.setLoop(true);
boulderSound.play();
sf::SoundBuffer sb2;
sb2.loadFromFile("assets/death.ogg");
fallingSound.setBuffer(sb2);
fallingSound.setRelativeToListener(true);
sf::SoundBuffer sb3;
sb3.loadFromFile("assets/jump.wav");
jumpingSound.setBuffer(sb3);
jumpingSound.setRelativeToListener(true);
sf::SoundBuffer sb4;
sb4.loadFromFile("assets/POL-flash-run-short.wav");
musicSound.setBuffer(sb4);
musicSound.setRelativeToListener(true);
musicSound.setVolume(15.f);
musicSound.setLoop(true);
musicSound.play();
sf::SoundBuffer sb5;
sb5.loadFromFile("assets/footsteps.ogg");
feetSound.setRelativeToListener(true);
feetSound.setBuffer(sb5);
feetSound.setLoop(true);
feetSound.setVolume(50);
feetSound.play();
sf::SoundBuffer sb6;
sb6.loadFromFile("assets/bump.ogg");
bumpSound.setRelativeToListener(true);
bumpSound.setBuffer(sb6);
bumpSound.setVolume(40);
sf::SoundBuffer sb7;
sb7.loadFromFile("assets/gem.ogg");
gemSound.setRelativeToListener(true);
gemSound.setBuffer(sb7);
gemSound.setVolume(60);
sf::SoundBuffer sb8;
sb8.loadFromFile("assets/Powerup3.wav");
powerSound.setRelativeToListener(true);
powerSound.setBuffer(sb8);
powerSound.setVolume(80);
sf::SoundBuffer sb9;
sb9.loadFromFile("assets/alert.ogg");
alertSound.setRelativeToListener(true);
alertSound.setBuffer(sb9);
//powerSound.setVolume(80);
// Create the SFML window
window.create(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "A Bolder Escape");
while (window.isOpen()) {
events();
if (!menu) logic();
render();
}
return 0;
}