new member + question about Cocos Denshion

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

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!

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 :)).

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.

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