Johan Sundhage new member + question about Cocos Denshion
Posts 5
Added by Johan Sundhage over 1 year ago

Hi everyone,

I've been lurking around this site for a couple of weeks and thought I'd better register and drop a line here. First I'll just have to say that this framework made me pretty comfortable with C++ in 2 weeks just as Cocos2d (Obj-C) taught me Objective C in about the same time. My learning-project has been a fairly simple 2d racing game. The only more advanced stuff is probably the threaded cUrl implementation for scores/ranking and ghost-data transmission to a backend; the rest is pure use of Cocos2d-x and Cocos Denshion...

During my development I noticed a wierd thing about SimpleAudioEngine. When I play some background music and pause it in my game, exit the app and then resume the app, the background music resumes automaticly. I am developing on an iPhone 4 and haven't tested it on Android yet. I read that someone had a simular problem with Cocos2d (obj-c), but the fix didn't seem to be compatible with Cocos2d-x. My current workaround is stopping the music instead of pausing when leaving the game.

cheers! // johan

Bin Zhang RE: new member + question about Cocos Denshion
Posts 62
Added by Bin Zhang over 1 year ago

Welcome to join us. And thanks for your feedback.

When I play some background music and pause it in my game, exit the app and then resume the app, the background music resumes automaticly.

It's because of the function AppDelegate::applicationWillEnterForeground() is invoked when you resume the app.
As default, the function invoked SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(), so the "problem" appeared.

You can modify the implementation of the method AppDelegate::applicationWillEnterForeground() to fit your native requirement.

Hope it's helpful!

Johan Sundhage RE: new member + question about Cocos Denshion
Posts 5
Added by Johan Sundhage over 1 year ago

Well, I removed that line and handle the resumeing depending on game state. Background music seem to resume even if I comment/remove all lines in AppDelegate::applicationWillEnterForeground()

Anyway, I'll create a test-case when there's time... Perhaps I've made some silly mistake somewhere (ones first C++ project has a tendency to end up a little bit messy :)).

Johan Sundhage RE: new member + question about Cocos Denshion
Posts 5
Added by Johan Sundhage over 1 year ago

I created a new project from template and the problem described above persist. I noticed it works fine when testing on simulator, but fails on device (iPhone 4).

I also get crashes when using CCDirector::sharedDirector()->pause(); in AppDelegate::applicationDidEnterBackground(), so I switched to CCDirector::sharedDirector()->stopAnimation();

Check out attached test project (XCode 3): tap to pause music, then leave app (press the button on device) and click the icon: music resumes. This does not happen in simulator.

DenshionFailX.zip - potential bug in SimpleAudioEngine when leaving/resumeing app on iPhone device (15 MB)

Oren Bengigi RE: new member + question about Cocos Denshion
Posts 107
Added by Oren Bengigi about 1 year ago

I'm having similar issues with the current Cocos2d-x version, but with sounds, not music.


(1-4/4)