MainScene* MainScene::Create() { MainScene* scene = new MainScene(); scene->Init(); return scene; }
void IPadSprite::ccTouchEnded(CCTouch* touch, CCEvent* event) { CCNode* pNode = this->getParent(); CCNode* pNode1 = this; while(pNode->getParent() != NULL) { pNode1 = pNode; pNode = pNode->getParent(); } MainScene* pScene = dynamic_cast<MainScene*>(pNode1); if(pScene) { pScene->hideMenu(); } MS5Layer* pLayer = dynamic_cast<MS5Layer*>(this->getParent()); if(pLayer) pLayer->hidePopupPanel(); this->setIsVisible(false); pNode = this->getParent(); pNode = pNode->getParent(); if(pNode->getChildByTag(TAG_IPAD_BIG) == NULL) { ScaleSprite* pSprite = ScaleSprite::scaleSpriteWithFile("ipad_big.png"); pSprite->setTag(TAG_IPAD_BIG); pSprite->setScale(0.24f); pSprite->setPosition( ccp(855, 420) ); pNode->addChild(pSprite, 2); pSprite->startScale(); } }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MainScene mainScene; if (!mainScene.initialize())return -1; mainScene.exec(); return 0; }
void ForwardLayer::onEnter(){ Layer::onEnter(); Size size = Director::getInstance()->getVisibleSize(); Vec2 origen = Director::getInstance()->getVisibleOrigin(); showsorce = cursorce; label = Label::createWithBMFont("futura-48.fnt",StringUtils::format("%dkb/s",showsorce)); label->setColor(cocos2d::Color3B::YELLOW); label->setPosition(size.width-100,size.height-20); this->addChild(label); /////////////////////////// MainScene *scene = dynamic_cast<MainScene *>(Director::getInstance()->getRunningScene()); auto layer = dynamic_cast<TouchLayer *>(scene->getChildByName("touchlayer")); ////////////////////暂停VS开始/////////////////////// auto item1 = MenuItemImage::create(); item1->setName("itme1"); item1->setNormalImage(Sprite::create("qianlei.png")); auto item2 = MenuItemImage::create(); item2->setName("itme2"); item2->setNormalImage(Sprite::create("light_skill.png")); MenuItemToggle*tog = MenuItemToggle::createWithCallback([=](Ref *sender){ auto m = dynamic_cast<MenuItemToggle*>(sender); auto n = m->getSelectedItem(); auto im = dynamic_cast<MenuItemImage*>(n); if (im->getName()=="itme2") { layer->setTouchStop(true); Director::getInstance()->pause(); ///暂停音效////////////////////////////////////////////////////////////////////////////////// SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); auto menulayer = MemuLayer::create(); menulayer->setName("layer"); scene->addChild(menulayer,100); } if (im->getName()=="itme1") { //开始 Director::getInstance()->resume(); //回复触摸 layer->setTouchStop(false); //开始音效/////////////////////////////////////////////////////////////////////////////////// SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); //移除菜单 scene->removeChildByName("layer"); /*layer->setTouchStop(true); Director::getInstance()->pause(); ///暂停音效////////////////////////////////////////////////////////////////////////////////// SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); MainScene *sne = dynamic_cast<MainScene *>(Director::getInstance()->getRunningScene()); auto menulayer = MemuLayer::create(); menulayer->setName("layer"); sne->addChild(menulayer);*/ } },item1,item2,NULL); Menu *mu = Menu::create(tog,NULL); mu->setPosition(size.width-110,origen.y+30); this->addChild(mu); }
void PauseLayer::onYesPressed(CCObject* sender) { MainScene* scene = (MainScene*)this->getParent(); scene->setPause(false); this->removeFromParentAndCleanup(true); if (_state == PauseLayerStateConfirmReplay) { this->replayButtonPressed(NULL); } else if (_state == PauseLayerStateConfirmTitle) { this->titleButtonPressed(NULL); } }
void MainLayer::onTouchMoved(Touch *pTouch, Event *pEvent) { // const CCPoint deltaPosition = pTouch->getDelta(); // BaseLayer::onTouchMoved(pTouch, pEvent); BaseScene* baseScene = static_cast<BaseScene*>(Director::getInstance()->getRunningScene()); if( baseScene->GetSceneType() == SceneType_MainScene ) { MainScene* mainScene = static_cast<MainScene*>(baseScene); mainScene->OnTouchMove(); } }
bool LevelTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) { if(index.isValid() && (role == Qt::DisplayRole || role == Qt::EditRole)) { MainScene *scene = static_cast<MainScene*>(itemFromIndex (index)); scene->setName(value.toString()); QModelIndex topLeft = index; QModelIndex bottomRight = index; emit dataChanged(topLeft, bottomRight); return true; } return false; }
bool MainLayer::onTouchBegan(Touch *pTouch, Event *pEvent) { // BaseLayer::onTouchBegan(pTouch, pEvent); BaseScene* baseScene = static_cast<BaseScene*>(Director::getInstance()->getRunningScene()); if( baseScene->GetSceneType() == SceneType_MainScene ) { MainScene* mainScene = static_cast<MainScene*>(baseScene); mainScene->OnTouchBegin(); } return true; }
MainScene* MainScene::create() { MainScene *pRet = new MainScene(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { CC_SAFE_DELETE(pRet); return NULL; } }
int main(int argc, char** argv) { { Game g; if (g.init()) { MainScene main; main.setIdentifier("mainScene"); g.addScene(&main); g.setActiveScene("mainScene"); g.start(); } } //std::cin.get(); return 0; }
CCScene* MainScene::createMainScene() { CCScene* scene = new CCScene; MainScene* pPlayer = new MainScene; if (pPlayer && pPlayer->Init()==true) { pPlayer->autorelease(); scene->addChild(pPlayer); return scene; } delete pPlayer; delete scene; return NULL; }
MainScene* MainScene::created() { MainScene *pRet = new MainScene(); if(pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = nullptr; return nullptr; } }
MainScene *MainScene::create() { MainScene *pRet = new MainScene(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } else { delete pRet; pRet = NULL; return NULL; } }
void MainLayer::onTouchEnded(Touch *pTouch, Event *pEvent) { // BaseLayer::onTouchEnded(pTouch, pEvent); const Point touchLocation = pTouch->getLocation(); BaseScene* baseScene = static_cast<BaseScene*>(Director::getInstance()->getRunningScene()); if( baseScene->GetSceneType() == SceneType_MainScene ) { MainScene* mainScene = static_cast<MainScene*>(baseScene); mainScene->OnTouchEnd(); } }
//1920x1080 //1920x864 //960x432 CCScene* MainScene::scene() { CCScene* pScene = CCScene::create(); MainScene* uiLayer = new MainScene(); if (uiLayer && uiLayer->init(pScene)) { uiLayer->autorelease(); pScene->addChild(uiLayer); } else { CC_SAFE_DELETE(uiLayer); } return pScene; }
CCScene* MainScene::scene ( KDint nLevel, KDint nStatus, KDint nLife ) { CCScene* pScene = CCScene::create ( ); MainScene* pLayer = new MainScene ( ); if ( pScene && pLayer && pLayer->initWithMapInformation ( nLevel, nStatus, nLife ) ) { pLayer->autorelease ( ); pScene->addChild ( pLayer ); } else { CC_SAFE_DELETE ( pScene ); CC_SAFE_DELETE ( pLayer ); } return pScene; }
void FinalProjectApp::mouseDown( MouseEvent event ) { ms.mouseDown(event); }
void FinalProjectApp::mouseMove( MouseEvent event ) { ms.mouseMove(event); }
void FinalProjectApp::mouseDrag( MouseEvent event ) { ms.mouseDrag(event); }
void FinalProjectApp::mouseUp( MouseEvent event ){ ms.mouseUp(event); }
void PauseLayer::onCancelPressed(CCObject* sender) { MainScene* scene = (MainScene*)this->getParent(); CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(FileUtils::getFilePath("SE/cancel.mp3").c_str()); scene->setPause(false); }