本文整理汇总了C++中Mix_HaltMusic函数的典型用法代码示例。如果您正苦于以下问题:C++ Mix_HaltMusic函数的具体用法?C++ Mix_HaltMusic怎么用?C++ Mix_HaltMusic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Mix_HaltMusic函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Mix_HaltMusic
void Sound::stopMusic()
{
Mix_HaltMusic();
printf("stop\n");
}
示例2: Mix_HaltMusic
void SDLManager::stopMusic()
{
if (SDLManager::musicPlaying() || SDLManager::musicPaused())
Mix_HaltMusic();
}
示例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;
}
示例4: Mix_HaltMusic
void SoundManager::stopMusic()
{
//Stop the music
Mix_HaltMusic();
}
示例5: StopSong
//
// StopSong
//
static void StopSong()
{
if (music)
Mix_HaltMusic();
}
示例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)
{
示例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)
//.........这里部分代码省略.........
示例8: destroystartscreen
void destroystartscreen() {
// SDL_FreeSurface(menu.getSurface());
menu.destroy();
Mix_HaltMusic();
Mix_FreeMusic(music);
}
示例9: destroymenu
void destroymenu() {
menu.destroy();
Mix_HaltMusic();
Mix_FreeMusic(music);
}
示例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 );
//.........这里部分代码省略.........
示例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;
示例12: Mix_HaltMusic
///////////////////////////////////////////////////////////
// ME stop
///////////////////////////////////////////////////////////
void Audio::ME_Stop() {
if (me_playing) {
Mix_HaltMusic();
me_playing = false;
}
}
示例13: Mix_HaltMusic
void GameSound::stopMusic()
{
Mix_HaltMusic();
musicPlaying = false;
myTimer->stop();
}
示例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;
}
示例15: S_StopMusic
/*
* @brief Stops music playback.
*/
static void S_StopMusic(void) {
Mix_HaltMusic();
s_music_state.current_music = NULL;
}