this is my cpp :
#include “SceneMenu.h”
#include “CCUserDefault.h”
#define MUSIC_FILE “loop2.mp3”
USING_NS_CC;
CCMenuItemImage **btnStart ,**btnGallery , **btnSound ,
**btnMan , **btnWoman ,**btnback;
CCMenu* pMenu;
bool isMute;
using namespace CocosDenshion;
CCScene* SceneMenu::scene()
{
// ‘scene’ is an autorelease object
CCScene scene = CCScene::node;
// ‘layer’ is an autorelease object
SceneMenulayer = SceneMenu::node();
// add layer as a child to scene
scene->addChild(layer);
isMute = CCUserDefault::sharedUserDefault()->getBoolForKey(“isMute”);
if(!isMute){
SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic(std::string(CCFileUtils::fullPathFromRelativePath(MUSIC_FILE)).c_str());
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(0.5);
if(!SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying()){
CCLog(“play background music”);
SimpleAudioEngine::sharedEngine()>playBackgroundMusic).c_str, true);
}
}
// return the scene
return scene;
}
bool SceneMenu::init
{
CCSize size = CCDirector::sharedDirector>getWinSize;
if )
{
return false;
}
CCSprite* pSprite = CCSprite::spriteWithFile;
pSprite~~>setPosition );
this~~>addChild(pSprite, 0);
return true;
}
this my .h file :
#ifndef SceneMenu_SCENE_H
#define SceneMenu_SCENE_H
#include “cocos2d.h”
#include “SceneGame.h”
#include “SimpleAudioEngine.h”
using namespace cocos2d;
class SceneMenu : public CCLayer
{
public:
// Here’s a difference. Method ‘init’ in cocos2d-x returns bool, instead of returning ‘id’ in cocos2d-iphone
virtual bool init();
// there’s no ‘id’ in cpp, so we recommand to return the exactly class pointer
static CCScene* scene();
// a selector callback
virtual void menuCloseCallback(CCObject* pSender);
void initBtn();
void initBtn2();
// implement the “static node()” method manually
LAYER_NODE_FUNC(SceneMenu);
};
when I call isMute = CCUserDefault::sharedUserDefault()->getBoolForKey(“isMute”); in the cpp file the simulator crash
any help ?
thanks