当前位置: 首页>>代码示例>>C++>>正文


C++ Sound::setVolume方法代码示例

本文整理汇总了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;
    }
开发者ID:KoczurekK,项目名称:Battle-of-Hrubieszow-old,代码行数:7,代码来源:soundsManager.hpp

示例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();
 }
开发者ID:mnewhouse,项目名称:tselements,代码行数:11,代码来源:sound_playback_controller.cpp

示例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);
                                        };
开发者ID:RichardSlade,项目名称:MscFinalProject,代码行数:23,代码来源:Entity.hpp

示例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;
}
开发者ID:lupuchard,项目名称:gamebase,代码行数:71,代码来源:main.cpp


注:本文中的sf::Sound::setVolume方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。