#include "MainScene.h"
#include "GameScene.h"
#include "SelectScene.h"
Scene* MainScene::createScene()
{
auto scene = Scene::create();
auto layer = MainScene::create();
scene->addChild(layer);
return scene;
}
bool MainScene::init()
{
//super init
if (!Layer::init())
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
Point origin = Director::getInstance()->getVisibleOrigin();
/////////////////////////////////////////////////////
AudioEngine::getInstance()->createLoop("bgm/main.ogg");
auto sceneNode = cocostudio::SceneReader::getInstance()->createNodeWithSceneFile("mainScene.json");
addChild(sceneNode);
auto UINode = sceneNode->getChildByTag(10005);
ExitNode = sceneNode->getChildByTag(10004);
DialogNode = sceneNode->getChildByTag(10006);
HelpNode = sceneNode->getChildByTag(10007);
OptionNode = sceneNode->getChildByTag(10008);
auto UIComponent = (cocostudio::ComRender*) UINode->getComponent("mainSceneUI");
auto ExitComponent = (cocostudio::ComRender*) ExitNode->getComponent("exitSelectUI");
auto DialogComponent = (cocostudio::ComRender*) DialogNode->getComponent("dialogBoxUI");
auto HelpComponent = (cocostudio::ComRender*) HelpNode->getComponent("helpUI");
auto OptionComponent = (cocostudio::ComRender*) OptionNode->getComponent("optionUI");
auto UILayer = (Layer*)UIComponent->getNode();
auto ExitLayer = (Layer*)ExitComponent->getNode();
auto DialogLayer = (Layer*)DialogComponent->getNode();
auto HelpLayer = (Layer*)HelpComponent->getNode();
auto OptionLayer = (Layer*)OptionComponent->getNode();
//////////
auto imageTable = dynamic_cast<ImageView*>(UILayer->getChildByTag(MAINSCENE_IMAGE_TABLE));
auto imagePaper = dynamic_cast<Button*>(UILayer->getChildByTag(MAINSCENE_IMAGE_PAPER));
auto imageShelf = dynamic_cast<Button*>(UILayer->getChildByTag(MAINSCENE_IMAGE_SHELF));
auto imageClock = dynamic_cast<ImageView*>(UILayer->getChildByTag(MAINSCENE_IMAGE_CLOCK));
auto imageCat = dynamic_cast<ImageView*>(UILayer->getChildByTag(MAINSCENE_IMAGE_CAT));
auto imageCharacter = dynamic_cast<ImageView*>(UILayer->getChildByTag(MAINSCENE_IMAGE_CHARACTER));
auto buttonOption = dynamic_cast<Button*>(UILayer->getChildByTag(MAINSCENE_BUTTON_OPTION));
auto buttonHelp = dynamic_cast<Button*>(UILayer->getChildByTag(MAINSCENE_BUTTON_HELP));
auto buttonExit = dynamic_cast<Button*>(UILayer->getChildByTag(MAINSCENE_BUTTON_EXIT));
imageTable->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
imagePaper->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
imageShelf->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
imageClock->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
imageCat->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
imageCharacter->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
buttonOption->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
buttonHelp->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
buttonExit->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
//////////
auto bgExit = dynamic_cast<ImageView*>(ExitLayer->getChildByTag(MAINSCENE_EXIT_BG));
auto buttonYes = dynamic_cast<Button*>(ExitLayer->getChildByTag(MAINSCENE_EXIT_BUTTON_YES));
auto buttonNo = dynamic_cast<Button*>(ExitLayer->getChildByTag(MAINSCENE_EXIT_BUTTON_NO));
bgExit->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
buttonYes->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
buttonNo->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
bgExit->setEnabled(false);
buttonYes->setEnabled(false);
buttonNo->setEnabled(false);
//////////
auto bgDialog = dynamic_cast<ImageView*>(DialogLayer->getChildByTag(MAINSCENE_DIALOG_BG));
bgDialog->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
bgDialog->setEnabled(false);
//////////
auto boxEasy = dynamic_cast<CheckBox*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_EASY));
auto boxHard = dynamic_cast<CheckBox*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_HARD));
auto boxScanline = dynamic_cast<CheckBox*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_SCANLINE));
auto sliderLag = dynamic_cast<Slider*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_SLIDER));
auto buttonClose = dynamic_cast<Button*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_CLOSE));
auto bgSetting = dynamic_cast<ImageView*>(OptionLayer->getChildByTag(MAINSCENE_SETTING_BG));
boxEasy->addEventListenerCheckBox(this, checkboxselectedeventselector(MainScene::checkboxEvent));
boxHard->addEventListenerCheckBox(this, checkboxselectedeventselector(MainScene::checkboxEvent));
boxScanline->addEventListenerCheckBox(this, checkboxselectedeventselector(MainScene::checkboxEvent));
sliderLag->addEventListenerSlider(this, sliderpercentchangedselector(MainScene::sliderEvent));
buttonClose->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
bgSetting->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
bgSetting->setEnabled(false);
buttonClose->setEnabled(false);
sliderLag->setEnabled(false);
boxEasy->setEnabled(false);
boxHard->setEnabled(false);
boxScanline->setEnabled(false);
//////////
auto pageHelp = dynamic_cast<PageView*>(HelpLayer->getChildByTag(MAINSCENE_HELP_PAGE));
auto bgHelp = dynamic_cast<ImageView*>(HelpLayer->getChildByTag(MAINSCENE_HELP_BG));
auto closeHelp = dynamic_cast<Button*>(HelpLayer->getChildByTag(MAINSCENE_HELP_CLOSE));
bgHelp->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
closeHelp->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
bgHelp->setEnabled(false);
closeHelp->setEnabled(false);
pageHelp->setEnabled(false);
return true;
}
void MainScene::onEnterTransitionDidFinish()
{
Layer::onEnterTransitionDidFinish();
/////////////////////////////////////////////////////
AudioEngine::getInstance()->play();
}
void MainScene::onExitTransitionDidStart()
{
Layer::onExitTransitionDidStart();
/////////////////////////////////////////////////////
AudioEngine::getInstance()->stop();
}
void MainScene::menuCloseCallback(Ref* pSender)
{
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}
void MainScene::createDialog(std::string key)
{
auto DialogComponent = (cocostudio::ComRender*) DialogNode->getComponent("dialogBoxUI");
auto DialogLayer = (Layer*)DialogComponent->getNode();
auto labelWord = dynamic_cast<Text*>(DialogLayer->getChildByTag(MAINSCENE_DIALOG_WORDS));
auto bgDialog = dynamic_cast<ImageView*>(DialogLayer->getChildByTag(MAINSCENE_DIALOG_BG));
ValueMap strings = FileUtils::getInstance()->getValueMapFromFile("strings.xml");
DialogNode->setVisible(true);
bgDialog->setEnabled(true);
labelWord->setString(strings.at(key).asString());
}
void MainScene::touchEvent(Ref* obj, TouchEventType eventType)
{
auto widget = dynamic_cast<Widget*>(obj);
int tag = widget->getTag();
auto ExitComponent = (cocostudio::ComRender*) ExitNode->getComponent("exitSelectUI");
auto DialogComponent = (cocostudio::ComRender*) DialogNode->getComponent("dialogBoxUI");
auto HelpComponent = (cocostudio::ComRender*) HelpNode->getComponent("helpUI");
auto OptionComponent = (cocostudio::ComRender*) OptionNode->getComponent("optionUI");
auto ExitLayer = (Layer*)ExitComponent->getNode();
auto DialogLayer = (Layer*)DialogComponent->getNode();
auto HelpLayer = (Layer*)HelpComponent->getNode();
auto OptionLayer = (Layer*)OptionComponent->getNode();
auto bgExit = dynamic_cast<ImageView*>(ExitLayer->getChildByTag(MAINSCENE_EXIT_BG));
auto bgDialog = dynamic_cast<ImageView*>(DialogLayer->getChildByTag(MAINSCENE_DIALOG_BG));
auto buttonYes = dynamic_cast<Button*>(ExitLayer->getChildByTag(MAINSCENE_EXIT_BUTTON_YES));
auto buttonNo = dynamic_cast<Button*>(ExitLayer->
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Cocos2d-x音乐手游Echo完整源代码 cocos精品小游戏源码 , 完整项目源码 是整个项目的压缩包 , 新建空项目直接导入到项目里面就可以运行了,无需其他操作。 适合二次开发和学习使用,都是经典游戏,需要其他游戏源码包可以看我主页。 直接可以运行 , 如果运行不了 请切换编译器版本 , 经过测试是没问题的 如果打不开请切换编译器版本。 有别的资源或代码需求可以通过我的主页联系 谢谢! cocos游戏代码 ,cocos经典游戏源码 , cocos休闲游戏源码, cocos容易上手的游戏源码,cocos小游戏源码,cocos新手练习源码,cocos个人开发源码,cocos优秀项目。
资源推荐
资源详情
资源评论
收起资源包目录
Cocos2d-x音乐手游Echo完整源代码 (155个子文件)
MainScene.cpp 13KB
GameScene.cpp 12KB
SelectScene.cpp 11KB
MapUtils.cpp 8KB
Note.cpp 6KB
ClearScene.cpp 6KB
AudioEngine.cpp 5KB
IntroScene.cpp 3KB
AppDelegate.cpp 1KB
main.cpp 451B
fmodexL.dll 322KB
fmodex.dll 281KB
fmodexp.dll 132KB
fmodapi40616win32-installer.exe 4.04MB
EchoMusic.vcxproj.filters 4KB
fmod.h 131KB
fmod_dsp.h 34KB
fmod_codec.h 13KB
fmod_errors.h 11KB
fmod_output.h 7KB
Global.h 3KB
SelectScene.h 856B
AudioEngine.h 850B
GameScene.h 787B
Note.h 753B
MainScene.h 742B
ClearScene.h 603B
MapUtils.h 522B
IntroScene.h 515B
resource.h 490B
AppDelegate.h 369B
main.h 267B
fmod.hpp 30KB
game.ico 47KB
helpUI.json 27KB
clearSceneUI.json 25KB
mainSceneUI.json 19KB
selectSceneUI.json 17KB
optionUI.json 15KB
gameSceneUI.json 13KB
pauseSelectUI.json 9KB
introSceneUI.json 8KB
loadingUI.json 8KB
exitSelectUI.json 7KB
dialogBoxUI.json 5KB
mainScene.json 4KB
gameScene.json 2KB
selectScene.json 2KB
clearScene.json 1KB
introScene.json 1KB
build-cfg.json 111B
fmodexp_vc.lib 193KB
fmodexL_vc.lib 193KB
fmodex_vc.lib 192KB
Stronger.mp3 4.43MB
Good boy.mp3 3.74MB
Relax,take it easy.mp3 3.46MB
manbursl.mp3 3.4MB
mbrsl.mp3 3.4MB
clear.ogg 1.67MB
main.ogg 1.61MB
intro.ogg 753KB
gameSceneBackground.png 912KB
background.png 895KB
songSelectBG.png 674KB
floor.png 637KB
clearSceneBackground.png 636KB
aboutBG.png 547KB
dialogBox.png 476KB
helpBG.png 433KB
optionBG.png 388KB
QAQ.png 313KB
logo.png 265KB
pauseBG.png 259KB
exitSelectBG.png 256KB
table.png 247KB
piano.png 237KB
shelf.png 230KB
echo1.png 223KB
character.png 134KB
P7.png 133KB
clock.png 130KB
P3.png 112KB
P4.png 111KB
P5.png 102KB
P2.png 95KB
P8.png 88KB
P6.png 82KB
book.png 79KB
bookBG.png 79KB
songinformationBG1.png 78KB
paper.png 77KB
songinformationBG.png 76KB
loadingBar.png 71KB
arrow.png 55KB
songinformationBG2.png 44KB
cat.png 41KB
P1.png 40KB
note2.png 37KB
booklight.png 37KB
共 155 条
- 1
- 2
资源评论
若风华浊世间
- 粉丝: 60
- 资源: 164
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功