linux怎么查看本机内存大小
229
2022-11-07
Cocos2d-X 声音菜单的打开和关闭
(1)头文件中 USING_NS_CC; USING_NS_CC_EXT; #include "SimpleAudioEngine.h" using namespace CocosDenshion; class LoginLayer:public CCLayer { public: virtual bool init(); SCENE_FUNC(LoginLayer); CREATE_FUNC(LoginLayer); //开关声音 void SoundOnOffClick(CCObject *sender); bool isSoundOpen; }; (2)实现文件中 bool LoginLayer::init() { if(!CCLayer::init()) { return false; } isSoundOpen=false; //添加声音按钮 CCMenuItemImage *soundbtnOn=CCMenuItemImage::create("soundon.png", "soundon.png"); CCMenuItemImage *soundbtnOff=CCMenuItemImage::create("soundoff.png", "soundoff.png"); CCMenuItemToggle *toggle=CCMenuItemToggle::createWithTarget(this, menu_selector(LoginLayer::SoundOnOffClick),soundbtnOn,soundbtnOff,NULL); toggle->setPosition(CCPointMake(0,0)); CCMenu *menu1=CCMenu::create(toggle,NULL); menu1->setPosition(ccp(50,50)); this->addChild(menu1); SimpleAudioEngine::sharedEngine()->playBackgroundMusic("yinyue.mp3", true); return true; } //声音的开与关的实现 void LoginLayer::SoundOnOffClick(CCObject *sender) { if(isSoundOpen) { SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); isSoundOpen=false; } else { SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); isSoundOpen=true; } }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~