这个场景作为d出场景,主要介绍下游戏。。。还有自己的联系方式(*^__^*) ……
主要使用文本,就一个返回按键的响应函数
//返回按钮voID back(EventKeyboard::KeyCode keyCode,Event* pEvent);
AboutGame::~AboutGame(){ _eventdispatcher->removeEventListenersForTarget(this);}
文本已在XML文件中生成,直接调用即可
bool AboutGame::init(){ if (!Layer::init()) return false; //背景音乐 CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(true); CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("sound/BackgroundMusic1.mp3",true); bool bRect = false; do { auto size = Director::getInstance()->getWinSize(); //设置背景图片 auto m_background = Sprite::createWithSpriteFramename("backgroundTollgateOne.png"); m_background->setposition(Vec2(size.wIDth/2,size.height/2)); m_background->setAnchorPoint(Vec2(0.5,0.5)); this->addChild(m_background); //设置监听器 auto m_Listener = EventListenerKeyboard::create(); m_Listener->onkeyreleased = CC_CALLBACK_2(AboutGame::back,this); _eventdispatcher->addEventListenerWithSceneGraPHPriority(m_Listener,this); //设置标签 并 获取中文文本 auto dictionary = Dictionary::createWithContentsOffile("Fonts/AboutMe.xml"); auto m_label3 = Label::createWithTTF( ((__String*)(dictionary->objectForKey("Others")))->getCString(),"Fonts/DFPShaoNvW5-GB.ttf",25 ); m_label3->setDimensions(size.wIDth / 3 * 2,size.height / 2); m_label3->setcolor(color3B(255,255,255)); m_label3->setposition(Point(size.wIDth / 2,size.height/2)); this->addChild(m_label3); auto m_label1 = Label::createWithTTF( ((__String*)(dictionary->objectForKey("AboutMe")))->getCString(),35 ); m_label1->setcolor(color3B(255,0)); m_label1->setposition( Point(size.wIDth/2,size.height-m_label3->getContentSize().height-m_label1->getContentSize().height) ); this->addChild(m_label1); auto m_label2 = Label::createWithTTF( ((__String*)(dictionary->objectForKey("QQ")))->getCString(),25 ); m_label2->setDimensions(size.wIDth / 3 * 2,size.height / 6); m_label2->setcolor(color3B(0,0)); m_label2->setposition(Point(size.wIDth / 2,m_label1->getpositionY() - m_label2->getContentSize().height)); this->addChild(m_label2); bRect = true; } while (0); return bRect;}//返回按钮voID AboutGame::back(EventKeyboard::KeyCode keyCode,Event* pEvent){ if (keyCode == EventKeyboard::KeyCode::KEY_ESCAPE) { //背景音乐 CocosDenshion::SimpleAudioEngine::getInstance()->stopBackgroundMusic(true); CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("sound/game_start.mp3",true); Director::getInstance()->popScene(); } }总结
以上是内存溢出为你收集整理的【cocos2d-x 3.7 飞机大战】 决战南海I (十一) 关于游戏场景全部内容,希望文章能够帮你解决【cocos2d-x 3.7 飞机大战】 决战南海I (十一) 关于游戏场景所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)