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


C++ Music::SetVolume方法代码示例

本文整理汇总了C++中Music::SetVolume方法的典型用法代码示例。如果您正苦于以下问题:C++ Music::SetVolume方法的具体用法?C++ Music::SetVolume怎么用?C++ Music::SetVolume使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Music的用法示例。


在下文中一共展示了Music::SetVolume方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Play

    bool Play( float fadeout, float fadein, Music &oldmusic )
    {
        if (m) {
            int fadesteps = fadeout*100;
            for (int i = fadesteps; i >= 0; i--) {
                oldmusic.SetVolume( i/(float) fadesteps );
                micro_sleep( 10000 );
            }
            Mix_FadeInMusic( m, 1, fadein ) != -1;
            micro_sleep( fadein*1000000 );

            return true;
        } else {
            return false;
        }
    }
开发者ID:vegastrike,项目名称:Vega-Strike-Engine-Source,代码行数:16,代码来源:soundserver.mac.notworking.cpp

示例2: Run

int Game::Run(RenderWindow &win, VideoMode &vMode)
{
	Music m;
	SoundBuffer playerShootBuffer;
	SoundBuffer meteorBuffer;
	meteorBuffer.LoadFromFile("..\\Resources\\meteorexplosion.ogg");
	playerShootBuffer.LoadFromFile("..\\Resources\\playerShoot.ogg");
	Sound playerSound;
	Sound meteorSound;
	meteorSound.SetBuffer(meteorBuffer);
	playerSound.SetBuffer(playerShootBuffer);
	playerSound.SetLoop(false);
	meteorSound.SetLoop(false);
	m.OpenFromFile("..\\Resources\\asteroid.ogg");
	
	m.SetLoop(true);
	m.SetVolume(100);
	PlayerShip ship(player_ship, 2, vMode);
	EnemyShip enemy(enemy_ship, vMode);
	Collision col;
	Event events;
	Image bg1;
	Image bg2;
	Image bg3;
	bg1.LoadFromFile("..\\Resources\\bg.jpg");
	Image stars;
	string abc = "..\\Resources\\star.png";
	stars.LoadFromFile(abc);
	Sprite sp(bg1);
	Sprite sp2(bg1);
	Sprite sp3(bg1);
	Sprite spStar[10];
	Clock clock;
	srand((unsigned)time(0)); 
	for(int i = 0; i<10; i++)
	{
		spStar[i].SetImage(stars);
		//spStar[i].SetPosition
	}
	spStar[0].SetPosition(0,100);
	spStar[1].SetPosition(70,200);
	spStar[2].SetPosition(200,300);
	spStar[3].SetPosition(320,400);
	spStar[4].SetPosition(460,500);
	spStar[5].SetPosition(260,300);
	spStar[6].SetPosition(160,400);
	spStar[7].SetPosition(400,200);
	spStar[8].SetPosition(760,100);
	spStar[9].SetPosition(800,600);
	

	int lowestx, highestx, lowesty, highesty, rangex, rangey, random_integerx, random_integery;
	float time1 = 0;
	float time2 = 0;
	bool start = false;

	



	
	//Sprite spStar1(stars);
	//spStar1.SetPosition(spStar.GetPosition().x, spStar.GetPosition().y - spStar.GetSize().y);
	sp.Resize((float)vMode.Width, (float)vMode.Height);
	sp2.Resize((float)vMode.Width, (float)vMode.Height);
	sp2.SetPosition(sp.GetPosition().x, sp.GetPosition().y - sp.GetSize().y);
	sp3.SetPosition(sp2.GetPosition().x, sp2.GetPosition().y - sp2.GetSize().y);
	//spStar.Resize((float)vMode.Width, (float)vMode.Height);
	bool key = false;
	bool down = false;
	Bullet *bul;
	Meteor* met[METEORCOUNT];
	for(int i = 0; i<METEORCOUNT; i++)
	{
		met[i] = new Meteor(meteor, vMode);
	}
	met[0]->SetPosition(200,-400);
	met[1]->SetPosition(420,-200);
	met[2]->SetPosition(720,-400);
	met[3]->SetPosition(520,-600);
	met[4]->SetPosition(320,-400);
	/*met[5]->SetPosition(620,-400);
	met[6]->SetPosition(100,-400);
*/
	int bulletCount = 0;
	vector<Bullet*> bulletVector;
	vector<Meteor*> meteorVector;
	for(int i = 0; i<METEORCOUNT; i++)
	{
		meteorVector.push_back(met[i]);
	}
	bool fired = false;
	bool pressed = false;
	int count;
	bool change = false;
	//win.UseVerticalSync(true);
	//win.SetFramerateLimit(60);
	int type = pistol;
	Image sunImg;
	sunImg.LoadFromFile("..\\Resources\\Sun.png");
//.........这里部分代码省略.........
开发者ID:rojanneo,项目名称:Asteroid_code,代码行数:101,代码来源:Game.cpp

示例3: main


//.........这里部分代码省略.........
    printf( "\n[CONNECTED]\n" );
    char ministr[2] = {'\0', '\0'};
    while (!done) {
//if ((Mix_PlayingMusic() || Mix_PausedMusic())&&(!done)) {
        char arg;
        std::string str;
        arg = INET_fgetc( mysocket );
        printf( "%c", arg );
        switch (arg)
        {
        case 'p':
        case 'P':
            arg = INET_fgetc( mysocket );
            while (arg != '\0' && arg != '\n') {
                if (arg != '\r') {
                    ministr[0] = arg;
                    str += ministr;
                }
                arg = INET_fgetc( mysocket );
            }
            printf( "%s", str.c_str() );
            if ( (str != curmus || invalid_string)
#ifdef HAVE_SDL
                || ( !Mix_PlayingMusic() )
#endif
                 ) {
                music = PlayMusic( str.c_str(), music );
                if (music.m) {
                    printf( "\n[PLAYING %s WITH %d FADEIN AND %d FADEOUT]\n", str.c_str(), fadein, fadeout );
                    curmus = str;
                    invalid_string = false;
                } else {
                    printf( "\n[UNABLE TO PLAY %s WITH %d FADEIN AND %d FADEOUT]\n", str.c_str(), fadein, fadeout );
                    music_finished();
                }
            } else {
                printf( "\n[%s WITH %d FADEIN AND %d FADEOUT IS ALREADY PLAYING]\n", str.c_str(), fadein, fadeout );
            }
            break;
        case 'i':
        case 'I':
            arg = INET_fgetc( mysocket );
            while (arg != '\0' && arg != '\n') {
                if (arg != '\r') {
                    ministr[0] = arg;
                    str += ministr;
                }
                arg = INET_fgetc( mysocket );
            }
            printf( "%s", str.c_str() );
            fadein = atoi( str.c_str() );
            printf( "\n[SETTING FADEIN TO %d]\n", fadein );
            break;
        case 'o':
        case 'O':
            arg = INET_fgetc( mysocket );
            while (arg != '\0' && arg != '\n') {
                if (arg != '\r') {
                    ministr[0] = arg;
                    str += ministr;
                }
                arg = INET_fgetc( mysocket );
            }
            printf( "%s", str.c_str() );
            fadeout = atoi( str.c_str() );
            printf( "\n[SETTING FADEOUT TO %d]\n", fadeout );
            break;
        case 'v':
        case 'V':
            arg = INET_fgetc( mysocket );
            while (arg != '\0' && arg != '\n') {
                if (arg != '\r') {
                    ministr[0] = arg;
                    str += ministr;
                }
                arg = INET_fgetc( mysocket );
            }
            printf( "%s", str.c_str() );
            volume = atof( str.c_str() );
            printf( "\n[SETTING VOLUME TO %f]\n", volume );
            music.SetVolume( volume );
            break;
        case 't':
        case 'T':
        case '\0':
            INET_close( mysocket );
            done = true;
            printf( "\n[TERMINATING MUSIC SERVER]\n" );
            break;
        }
    }
    //free & close
    INET_cleanup();
#ifdef HAVE_SDL
    Mix_CloseAudio();
    SDL_Quit();
#endif

    return 0;
}
开发者ID:vegastrike,项目名称:Vega-Strike-Engine-Source,代码行数:101,代码来源:soundserver.mac.notworking.cpp


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