Saturday 15 May 2010

Cocos2d CocosDenshion Sound Engine stop error -



Cocos2d CocosDenshion Sound Engine stop error -

thanks taking time question, new programming , having problem next error. help appreciated.

i learning via ray wenderlichs 'learning cocos2d' book experiment code effort larn more , have run problem can not fix.

i using cocosdenshion play music tracks main menu , first gameplay scene, ray advises in book phone call next method gameplay scene...

[[gamemanager sharedgamemanager] playbackgroundtrack:backgound_track_ole_awakes];

this of course of study works rather phone call above method in gameplay scene want command start , stopping of music gamemanager class. want music play in menu , nil play on gameplay layer , command 1 class.

to have attempted add together next in "gamemanager.h.".

if (soundengine.isbackgroundmusicplaying == yes) { [soundengine stopbackgroundmusic]; }

in method below...

- (nsstring*)formatscenetypetostring:(scenetypes)sceneid { nsstring *result = nil; switch(sceneid) { case knosceneuninitialized: if ((soundengine.isbackgroundmusicplaying == yes)){ [soundengine stopbackgroundmusic]; } result = @"knosceneuninitialized"; break; case kmainmenuscene: if ((issoundeffectson == yes)&&(soundengine.isbackgroundmusicplaying == no)){ [self playbackgroundtrack:background_track_main_menu]; } else if ((issoundeffectson == no)&&(soundengine.isbackgroundmusicplaying == yes)){ [soundengine stopbackgroundmusic]; } if (ismusicon == yes) { result = @"kmainmenuscene"; } else if (ismusicon == no) { result = @"knosceneuninitialized"; // homecoming no; } break; case koptionsscene: if ((issoundeffectson == yes)&&(soundengine.isbackgroundmusicplaying == no)){ [self playbackgroundtrack:background_track_main_menu]; } else if ((issoundeffectson == no)&&(soundengine.isbackgroundmusicplaying == yes)){ [soundengine stopbackgroundmusic]; } if (ismusicon == yes) { result = @"koptionsscene"; } else if (ismusicon == no) { // homecoming no; result = @"knosceneuninitialized"; } break; case kgamelevel1: if ([soundengine.isbackgroundmusicplaying == yes]){ [soundengine stopbackgroundmusic]; <--crashes here! } else { } result = @"kgamelevel1"; break;

now above works fine main menu , options screens when run seems crash when effort load gamelevel1 screen. crash seems occur 1 time every , confusing least.

when crashes takes me next in cdaudiomanager.h..

-(bool) isplaying { if (state != klas_init) { homecoming [audiosourceplayer isplaying]; <--thread 18:exc_bad_access(code=1,address=0x8001400c) } else { homecoming no; } }

i below in console...

2014-10-28 12:46:03.948 spaceviking[1807:343] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[ccstandardtouchhandler isplaying]: unrecognized selector sent instance 0x7e013d80' *** first throw phone call stack: ( 0 corefoundation 0x05bb25e4 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x025658b6 objc_exception_throw + 44 2 corefoundation 0x05c4f903 -[nsobject(nsobject) doesnotrecognizeselector:] + 275 3 corefoundation 0x05ba290b ___forwarding___ + 1019 4 corefoundation 0x05ba24ee _cf_forwarding_prep_0 + 14 5 spaceviking 0x00183e72 -[cdlongaudiosource isplaying] + 82 6 spaceviking 0x00185425 -[cdaudiomanager isbackgroundmusicplaying] + 69 7 spaceviking 0x0018ea60 -[simpleaudioengine isbackgroundmusicplaying] + 48 8 spaceviking 0x0019fe62 -[gamemanager formatscenetypetostring:] + 9634 9 spaceviking 0x001a095e -[gamemanager getsoundeffectslistforscenewithid:] + 2302 10 spaceviking 0x0019d50a -[gamemanager unloadaudioforscenewithid:] + 186 11 foundation 0x01e39597 -[nsthread main] + 76 12 foundation 0x01e394f6 __nsthread__main__ + 1275 13 libsystem_pthread.dylib 0x02d185fb _pthread_body + 144 14 libsystem_pthread.dylib 0x02d18485 _pthread_struct_init + 0 15 libsystem_pthread.dylib 0x02d1dcf2 thread_start + 34 ) libc++abi.dylib: terminating uncaught exception of type nsexception (lldb)

sorry length of question wanted seek , include much info possible.

edit

i wrong if sound engine called 2 different classes cause this? have next in mainmenu layer...

-(void)playscene:(ccmenuitemfont*)itempassedin { if ([itempassedin tag] == 1) { cclog(@"tag 1 found, mode"); if ([gamemanager sharedgamemanager].issoundeffectson ==yes ) { playsoundeffect(buttonpress); <----calling sound engine play sound on button press.- unloading sound level1 starts. [[gamemanager sharedgamemanager] runscenewithid:kgamelevel1]; }else if ([gamemanager sharedgamemanager].issoundeffectson ==no ) { [[gamemanager sharedgamemanager] runscenewithid:kgamelevel1]; return; }

cocos2d-iphone

No comments:

Post a Comment