• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Mix_HaltMusic函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Mix_HaltMusic函数的典型用法代码示例。如果您正苦于以下问题:C++ Mix_HaltMusic函数的具体用法?C++ Mix_HaltMusic怎么用?C++ Mix_HaltMusic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: Mix_HaltMusic

void Sound::stopMusic()
{
    Mix_HaltMusic();
	printf("stop\n");
}
开发者ID:bdragon917,项目名称:mPULSE,代码行数:5,代码来源:Sound.cpp


示例2: Mix_HaltMusic

void SDLManager::stopMusic()
{
	if (SDLManager::musicPlaying() || SDLManager::musicPaused())
		Mix_HaltMusic();
}
开发者ID:alexdantas,项目名称:sdl-toe,代码行数:5,代码来源:SDLManager.cpp


示例3: AUDs_PlayAudioStream

// play specified stream file -------------------------------------------------
//
int AUDs_PlayAudioStream( char *fname )
{

    if (SoundDisabled)
		return 1;
    
    ASSERT(fname!=NULL);
    
    if (Mix_PlayingMusic())
		Mix_HaltMusic();
	
    if (music != NULL) { 
         Mix_FreeMusic(music);
         FREEMEM(tmp_music_buffer);
         tmp_music_buffer = NULL;
         music = NULL;
    }
    // because SDL_RWFromFP doesn't work cross platform, we need
	// to get a little bit kinky
    
	// set up a buffer for the file
	
	size_t tmp_music_size = 0;
    
	// get the size of this sample
	tmp_music_size = SYS_GetFileLength(fname);
	if (tmp_music_size <= 0) {
		return 1; // return on error
	}
    
	// alloc space for the buffer
    if (tmp_music_buffer != NULL) {
        printf("ERROR: Shouldn't be this far without being cleaned up previously\n");
        FREEMEM(tmp_music_buffer);
        tmp_music_buffer = NULL;
    }
	
	tmp_music_buffer = (char *)ALLOCMEM(tmp_music_size + 1);
    
	// open the sample file
	FILE *musicfp = SYS_fopen(fname, "rb");
    if (musicfp == NULL)
		return 1;
    
	// read the file into the temp_sample_buffer
	int read_rc = SYS_fread((void *)tmp_music_buffer, 1, tmp_music_size, musicfp);
    
	if(read_rc <= 0) {
		MSGOUT("ERROR: Error reading music %s.", fname);
		return FALSE;
	}

	SDL_RWops *musicrwops = SDL_RWFromMem((void *)tmp_music_buffer, tmp_music_size);

    music = Mix_LoadMUS_RW(musicrwops, 1);
    //MSGOUT("      PlayAudioStream() with %s       ", fname);
    if (music == NULL) {
		printf("Mix_LoadMUS(\"%s\"): %s\n", fname, Mix_GetError());
		// this might be a critical error...
		FREEMEM(tmp_music_buffer);
		tmp_music_buffer = NULL;
		return 1;
    }
    
    Mix_VolumeMusic(128);
	
    if (music != NULL) {
    	Mix_PlayMusic(music, 0);
    }
	
    //Pick up your your toys when you finish
    SYS_fclose(musicfp);
   
    return 1;
}
开发者ID:OpenParsec,项目名称:openparsec,代码行数:77,代码来源:aud_sdlmixer.cpp


示例4: Mix_HaltMusic

void SoundManager::stopMusic()
{
    //Stop the music
    Mix_HaltMusic();
}
开发者ID:JamesSinnott1994,项目名称:FYP,代码行数:5,代码来源:SoundManager.cpp


示例5: StopSong

//
// StopSong
//
static void StopSong()
{
    if (music)
        Mix_HaltMusic();
}
开发者ID:jasoncarlough,项目名称:doomretro,代码行数:8,代码来源:main.cpp


示例6: welcome_main


//.........这里部分代码省略.........
                                    animate_button(button[0],0);
                                     welcome = false;
                                     option = 1;
                                     break;
                                
                                case SDLK_x:
                                    animate_button(button[4],4);
                                     welcome = false;
                                     option = -1;
                                     break;
                                
                                case SDLK_1:
                                    
                                    if(Mix_PlayingMusic() == 0)
                                    {
                                        Mix_PlayMusic(background_music,-1);
                                    }
                                    else
                                    {
                                        if(Mix_PausedMusic() == 1)
                                        {
                                            sound = true;
                                            Mix_ResumeMusic();
                                        }
                                        else
                                        {
                                            sound = false;
                                            Mix_PauseMusic();
                                        }
                                    }
                                    break;
                                
                                case SDLK_0:
                                    Mix_HaltMusic();
                                    break;
                         }
                    }
             }          
        //---=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
        while(option_screen == true)
        {
            if(first_run)
            {
            draw_image(option_screen_image,screen,NULL,0,0);
            
            draw_image(back_button_image,screen,NULL,back_button.dimension.x, back_button.dimension.y);
            first_run = false;
            }
            draw_image(sound_icon[sound],screen,NULL,sound_button.dimension.x,sound_button.dimension.y);
            while(SDL_PollEvent(&event))
            {
                switch(event.type)
                {
                    case SDL_MOUSEBUTTONDOWN:
                        
                        if(sound)Mix_PlayChannel(-1,click_sound,0);
                        mx = event.button.x;
                        my = event.button.y;
                         
                        if(check_click(sound_button,mx,my) == true)
                        {
                            if(sound == 0) sound = 1;
                            else sound =0;
                        }
                        if(check_click(back_button,mx,my)== true)
                        {
开发者ID:pranay-91,项目名称:tank-game,代码行数:67,代码来源:welcome.c


示例7: displayAbout

int displayAbout(SDL_Surface *screen, dataStore *data)
{
	int done, mouseX, mouseY;
	SDL_Event event;

	SDL_Color textColor = { 255, 255, 255,0};
	
	SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0x00, 0x00, 0x00 ));

	myButton button;
	button.rect.x = screen->clip_rect.w/2-BUTTONWIDTH/2;
	button.rect.y = screen->clip_rect.h-BUTTONHEIGHT-100;
	button.rect.w = BUTTONWIDTH;
	button.rect.h = BUTTONHEIGHT;
	button.name="Back";
	
	drawButton(screen, &button);
	
	TTF_Font *font = theFont(20);
	char aboutText[10][100] = {"Hedgewood is a game written by:"," - toco"," - tk"," - JTR"," "," we hope you enjoy it."," ","Thanks to:"," - friend of tk for the grapics"," - our great tutor Arne"};
	
	if (!(renderMultiLineText(font, 150, 100, &aboutText[0],10, textColor,screen)))
		printf("%s\n",TTF_GetError());
	
	
	SDL_Flip(screen);
	TTF_CloseFont(font);

//	SDL_FreeSurface(message);
	unsigned int startTime, stopTime, diffTime;
	unsigned int innerStartTime, innerStopTime;
	
	done = 0;
	while ( !done ) {
		startTime = SDL_GetTicks();
		/* Check for events */
		while ( SDL_PollEvent(&event) ) {
			innerStartTime = SDL_GetTicks();
			switch (event.type) {
					
				case SDL_MOUSEMOTION:
					break;
				case SDL_MOUSEBUTTONUP:
					
					SDL_GetMouseState(&mouseX,&mouseY);
					if (isButtonClicked(&button, mouseX, mouseY)) {
						
						done = 1;
					}
#if (DEBUG==1)
					printf("Cusor-Position x: %d y: %d\n",mouseX,mouseY);
#endif
					break;
				case SDL_KEYDOWN:
					/* Any keypress quits the app... */
					switch( event.key.keysym.sym )
				{
					case SDLK_f:
						break;
						
					case SDLK_0:
						printf ("Music off\n");
						Mix_HaltMusic();
						Mix_HaltChannel(-1);
						data->soundEnabled=0;
						break;
					case 	SDLK_m:
						printf ("Music on /Pause\n");				
						if( Mix_PlayingMusic() == 0 )  
							Mix_PlayMusic( data->ingamemusic, -1);			
						if( Mix_PausedMusic() == 1 )
							Mix_ResumeMusic(); 
						else Mix_PauseMusic();						
						break;
					case SDLK_ESCAPE:
					case SDLK_q:
						done = 1;
						quitSDL(data);
						break;
					default:
						break;
						
				}	
					break;
/*				case SDL_QUIT:
					done = 1;
					break;
*/				default:
					break;
			}
			innerStopTime = SDL_GetTicks();
			diffTime=(innerStopTime-innerStartTime);
			//25 Frames per second (40 Milliseconds per frame)
			if (MS_FRAMETIME>diffTime) 
				SDL_Delay(MS_FRAMETIME-diffTime);
		}
		stopTime = SDL_GetTicks();
		diffTime = (stopTime-startTime);
		//25 Frames per second (40 Milliseconds per frame)
		if (MS_FRAMETIME>diffTime) 
//.........这里部分代码省略.........
开发者ID:toco,项目名称:hedgewood,代码行数:101,代码来源:about.c


示例8: destroystartscreen

void destroystartscreen() {
//	 SDL_FreeSurface(menu.getSurface());
     menu.destroy();
     Mix_HaltMusic();
     Mix_FreeMusic(music);
}
开发者ID:kennycason,项目名称:kennycason,代码行数:6,代码来源:menu.cpp


示例9: destroymenu

void destroymenu() {
    menu.destroy();
     Mix_HaltMusic();
     Mix_FreeMusic(music);
}
开发者ID:kennycason,项目名称:kennycason,代码行数:5,代码来源:menu.cpp


示例10: main

int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}
					//Handle key press
					else if( e.type == SDL_KEYDOWN )
					{
						switch( e.key.keysym.sym )
						{
							//Play high sound effect
							case SDLK_1:
							Mix_PlayChannel( -1, gHigh, 0 );
							break;

							//Play medium sound effect
							case SDLK_2:
							Mix_PlayChannel( -1, gMedium, 0 );
							break;

							//Play low sound effect
							case SDLK_3:
							Mix_PlayChannel( -1, gLow, 0 );
							break;

							//Play scratch sound effect
							case SDLK_4:
							Mix_PlayChannel( -1, gScratch, 0 );
							break;

							case SDLK_9:
							//If there is no music playing
							if( Mix_PlayingMusic() == 0 )
							{
								//Play the music
								Mix_PlayMusic( gMusic, -1 );
							}
							//If music is being played
							else
							{
								//If the music is paused
								if( Mix_PausedMusic() == 1 )
								{
									//Resume the music
									Mix_ResumeMusic();
								}
								//If the music is playing
								else
								{
									//Pause the music
									Mix_PauseMusic();
								}
							}
							break;

							case SDLK_0:
							//Stop the music
							Mix_HaltMusic();
							break;
						}
					}
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render prompt
				gPromptTexture.render( 0, 0 );

				//Update screen
				SDL_RenderPresent( gRenderer );
//.........这里部分代码省略.........
开发者ID:mariontan,项目名称:LazyFooTrials,代码行数:101,代码来源:21_sound_effects_and_music.cpp


示例11: main


//.........这里部分代码省略.........
				//		slog("left is down");	
						mew.playerX += 3;
						mew.accel = (mew.accel - .000001);
						break;

						case SDLK_RIGHT:
					//	slog("right is down");
						mew.playerX -= 3;
						mew.accel = (mew.accel - .000001);
						break;

						case SDLK_UP:
					//	slog("up is down");
						 mew.accel = (mew.accel + .00007);
						 Mix_PlayChannel( 1, buzz, 0 );
						 break;
						
						case SDLK_DOWN:
					//	slog("down is down");
						mew.accel = (mew.accel - .00008);
						break;
						}
					}

					else if( e.type == SDL_KEYUP )
					{
						//Select surfaces based on key press
						switch( e.key.keysym.sym )
						{	
						
						case SDLK_RETURN :
						if(mew.done ==1)
						{
							Mix_HaltMusic();
							if(GP == 1)
							{
							mew.done=0;
							lvl++;
							//slog("new level is %i",lvl);
							mew.position = 0;
							rival.position =0;
							setWorld();
							Results(mew.rank,lvl);
							}
						else if (GP == 0)
							{
							mew.done=0;
							mew.position = 0;
							rival.position =0;
							levelSelect();
							}
						
						}
						else
						{
						slog("too soon");
						}
						
						case SDLK_LEFT:
					//	slog("left is up");	
						e.type = SDLK_CLEAR;
						break;

						case SDLK_RIGHT:
					//	slog("right is up");
						e.type = SDLK_CLEAR;
开发者ID:mtl23,项目名称:2DFINAL,代码行数:67,代码来源:game.c


示例12: Mix_HaltMusic

///////////////////////////////////////////////////////////
// ME stop
///////////////////////////////////////////////////////////
void Audio::ME_Stop() {
	if (me_playing) {
		Mix_HaltMusic();
		me_playing = false;
	}
}
开发者ID:cstrahan,项目名称:argss,代码行数:9,代码来源:audio_sdl.cpp


示例13: Mix_HaltMusic

void GameSound::stopMusic()
{
  Mix_HaltMusic();
  musicPlaying = false;
  myTimer->stop();
}
开发者ID:SanskritFritz,项目名称:bubble-chains,代码行数:6,代码来源:gamesound.cpp


示例14: main


//.........这里部分代码省略.........
     
     SDL_FreeSurface( message );
     
     message = TTF_RenderText_Solid( font, "Press 0 to stop the music", textColor );
     
     if( message == NULL )
         return 1;
     
     apply_surface( ( SCREEN_WIDTH - message->w ) / 2, 300, message, screen );
     
     SDL_FreeSurface( message );
     
     if( SDL_Flip( screen ) == -1 )
         return 1;
         
     while( quit == false)
     {
            while( SDL_PollEvent(&event) )
            {
                                    
                   if( event.type == SDL_KEYDOWN )
                   {
                       if( event.key.keysym.sym == SDLK_1 )
                       {
                           //play scratch
                           if( Mix_PlayChannel( -1, scratch, 0 ) == -1 )
                               return 1;
                       }
                       else if( event.key.keysym.sym == SDLK_2 )
                       {
                           //play high
                           if( Mix_PlayChannel( -1, high, 0 ) == -1 )
                               return 1;
                       }
                       else if( event.key.keysym.sym == SDLK_3 )
                       {
                           //play med
                           if( Mix_PlayChannel( -1, med, 0 ) == -1 )
                               return 1;
                       }
                       else if( event.key.keysym.sym == SDLK_4 )
                       {
                           //play low
                           if( Mix_PlayChannel( -1, low, 0 ) == -1 )
                               return 1;
                       }
                       else if( event.key.keysym.sym == SDLK_9 )
                       {
                            //if no music
                            if( Mix_PlayingMusic() == 0 )
                            {
                                //play music
                                if( Mix_PlayMusic( music, -1 ) == -1 )
                                    return 1;
                            }
                            else
                            {
                                if( Mix_PausedMusic() == 1 )
                                    Mix_ResumeMusic();
                                else
                                    Mix_PauseMusic();
                            }
                       }
                       else if( event.key.keysym.sym == SDLK_0 )
                            Mix_HaltMusic();
                   }
                       
                   
                   if( event.type == SDL_QUIT )
                       quit = true;
            }
            
         
         /*
         Uint8 *keystates = SDL_GetKeyState( NULL );
         //if up
         if( keystates[ SDLK_UP ] )
         {
             apply_surface( ( SCREEN_WIDTH - up->w ) / 2, ( SCREEN_HEIGHT / 2 - up->h ) / 2, up, screen );
         }
         
         //if down
         if( keystates[ SDLK_DOWN ] )
             apply_surface( ( SCREEN_WIDTH - down->w ) / 2, ( SCREEN_HEIGHT / 2 - down->h ) / 2 + ( SCREEN_HEIGHT / 2 ), down, screen );
         
         //if left
         if( keystates[ SDLK_LEFT ] )
             apply_surface( ( SCREEN_WIDTH / 2 - left->w ) / 2, ( SCREEN_HEIGHT - left->h ) / 2, left, screen );
         //if right
         if( keystates[ SDLK_RIGHT ] )
             apply_surface( ( SCREEN_WIDTH / 2 - right->w ) / 2 + (SCREEN_WIDTH / 2 ), ( SCREEN_HEIGHT - right->h ) / 2, right, screen );
             
         if( SDL_Flip( screen ) == -1 )
             return 1;
             */
     }
     
     clean_up();
     return 0;
}
开发者ID:felesmortis,项目名称:graphicsAssorted,代码行数:101,代码来源:SDL11.cpp


示例15: S_StopMusic

/*
 * @brief Stops music playback.
 */
static void S_StopMusic(void) {

	Mix_HaltMusic();

	s_music_state.current_music = NULL;
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:9,代码来源:s_music.c


示例16: playing

void SDLAudio::stopMusic()          // Stop just the music that is currently playing (does not stop any sounds)
{
  Mix_HaltMusic();
}
开发者ID:justfielding,项目名称:elle-legacy,代码行数:4,代码来源:SDLAudio.cpp


示例17: Mix_HaltMusic

void AudioManager::stopMusic()
{
	Mix_HaltMusic();
}
开发者ID:EmbiaWu,项目名称:the-pintos-within,代码行数:4,代码来源:AudioManager.cpp


示例18: Mix_HaltMusic

void CMusic::Stop()
{
	Mix_HaltMusic();
}
开发者ID:skdeng,项目名称:opengl_project,代码行数:4,代码来源:Sound.cpp


示例19: Mix_HaltMusic

void Music::stop()
{
	Mix_HaltMusic();
    Log::debug("Music::stop");
}
开发者ID:AutonomicStudios,项目名称:sdl2-platformer,代码行数:5,代码来源:Music.cpp


示例20: main


//.........这里部分代码省略.........
					g_game->dbgNextPumpkin( BLACKBIRD );
					break;

				case SDLK_8:
					g_game->dbgClearQueue();
					break;
#endif


				case SDLK_s:
					ilutGLScreenie();
					break; 

				case SDLK_d:
					bDrawGamepad = !bDrawGamepad;
					break;

				case SDLK_m:					

					if (!musicOn) {
						printf("Playing\n");
						if (g_state==STATE_TITLE) {
							Mix_PlayMusic( music_title, -1 );
						} else if (g_state==STATE_PLAYING) {
							Mix_PlayMusic( music_ingame, -1 );
						} else if (g_state==STATE_GAMEOVER) {
							// easter egg.. kindof.. you get to hear the
							// game over music again. woo.
							Mix_PlayMusic( music_gameover, 0 );
						}
						musicOn = 1;
					} else {
						printf("Halting\n");
						Mix_HaltMusic();
						musicOn = 0;
					}


				case SDLK_LEFT:
					g_view->nextStation();
					break;
				case SDLK_RIGHT:
					g_view->prevStation();
					break;

				case SDLK_SPACE:
				case SDLK_RETURN:
					if (g_state == STATE_PLAYING) {
						doActivateStation();
					} else {
						doStartButton();
					}
					
					break;

				case SDLK_UP:
					if (g_state==STATE_PLAYING) {
						//g_view->activateStation();
						doActivateStation();
					} else if (g_state==STATE_TITLE ) {
						prevMenuItem();						
					}
					break;

				case SDLK_DOWN:
					if (g_state==STATE_TITLE ) {
开发者ID:bradparks,项目名称:ld48jovoc_food_fight_3d_luxe,代码行数:67,代码来源:TheHalloweenMachine.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Mix_HookMusicFinished函数代码示例发布时间:2022-05-30
下一篇:
C++ Mix_HaltChannel函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap