void HubLayer::AchievementsLayerButtonCallback(cocos2d::Ref* pSender, cocos2d::ui::Widget::TouchEventType type) { if (type == Widget::TouchEventType::ENDED) { if (GameScene::getInstance()->hasXblContext()) { hideLayer(); GameScene::getInstance()->m_achievementsLayer = AchievementsLayer::create(); GameScene::getInstance()->m_achievementsLayer->attachToScene(GameScene::getInstance()); } } }
void Window::sendPaths() { if (settings) { hideSettings(); } else { if (layerShown()) { hideLayer(); } if (main && !main->animating()) { main->activate(); } } }
void Window::sendPaths() { if (_mediaView && !_mediaView->isHidden()) _mediaView->hide(); if (settings) { hideSettings(); } else { if (layerShown()) { hideLayer(); } if (main && !main->animating()) { main->activate(); } } }
bool HubLayer::init() { ////////////////////////////// // 1. super init first if (!Layer::init()) { return false; } auto visibleSize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); // Add Achievements Scene Button { m_achievemntsLayerButton = Button::create("images/ButtonExtended.png", "images/ButtonPressedExtended.png"); if (m_achievemntsLayerButton == nullptr || m_achievemntsLayerButton->getContentSize().width <= 0.0f || m_achievemntsLayerButton->getContentSize().height <= 0.0f) { SampleLog(LL_WARNING, "'Achievements' Module Button failed to load icons!"); } else { float x = origin.x + visibleSize.width/2.0f; float y = origin.y + visibleSize.height - m_achievemntsLayerButton->getContentSize().height/2.0f; y -= m_achievemntsLayerButton->getContentSize().height*3; m_achievemntsLayerButton->setPosition(Vec2(x,y)); m_achievemntsLayerButton->addTouchEventListener(CC_CALLBACK_2(HubLayer::AchievementsLayerButtonCallback, this)); m_achievemntsLayerButton->setTitleFontName(TEXT_FONT_NAME); m_achievemntsLayerButton->setTitleText("ACHIEVEMENTS"); m_achievemntsLayerButton->setTitleFontSize(16.0f); this->addChild(m_achievemntsLayerButton); } } hideLayer(); return true; }
void browsers::LayerButton::OnLeftClick(wxMouseEvent &event) { if (event.ShiftDown()) //Lock layer { //_hidden = !_hidden; hideLayer(!_hidden); wxString cmd; cmd << wxT("hidelayer(") <<_layer->layno() << wxT(", "); if (_hidden) cmd << wxT("true") << wxT(");"); else cmd << wxT("false") << wxT(");"); Console->parseCommand(cmd); } else //Select layer { wxString cmd; cmd << wxT("usinglayer(") << _layer->layno()<< wxT(");"); Console->parseCommand(cmd); if (!_selected) { select(); //Next block uses for unselect previous button int bt = BT_LAYER_SELECT; wxCommandEvent eventLAYER_SELECT(wxEVT_CMD_BROWSER); eventLAYER_SELECT.SetExtraLong(_layer->layno()); eventLAYER_SELECT.SetInt(bt); wxPostEvent(Browsers->TDTlayers()->getLayerPanel(), eventLAYER_SELECT); } } }
void UICtrl::onEnter(){ Layer::onEnter(); auto vSize = Director::getInstance()->getVisibleSize(); playLayer = Layer::create(); playLayer->setCascadeOpacityEnabled(true); playLayer->setOpacity(GLubyte(255*0.6)); addChild(playLayer,10); auto stopButton = Sprite::create("stopButton.png"); stopButton->setPosition(vSize); stopButton->setAnchorPoint(Vec2(1.0f,1.0f)); playLayer->addChild(stopButton); auto leftButton = Sprite::create("leftButton.png"); leftButton->setPosition(Vec2(0,0)); leftButton->setAnchorPoint(Vec2(0,0)); playLayer->addChild(leftButton); auto rightButton = Sprite::create("rightButton.png"); rightButton->setPosition(Vec2(100,0)); rightButton->setAnchorPoint(Vec2(0,0)); playLayer->addChild(rightButton); moveButton = Sprite::create("moveButton2.png"); moveButton->setPosition(Vec2(780,0)); moveButton->setAnchorPoint(Vec2(1,0)); playLayer->addChild(moveButton); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(UICtrl::showBuff), strShowBuff, NULL); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(UICtrl::hideBuff), strHideBuff, NULL); NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(UICtrl::dieShow), strDieShow, NULL); auto hitButton = Sprite::create("hitButton.png"); hitButton->setPosition(Vec2(870,0)); hitButton->setAnchorPoint(Vec2(1,0)); playLayer->addChild(hitButton); auto jumpButton = Sprite::create("jumpButton.png"); jumpButton->setPosition(Vec2(960,0)); jumpButton->setAnchorPoint(Vec2(1,0)); playLayer->addChild(jumpButton); stopLayer = Layer::create(); stopLayer->setCascadeOpacityEnabled(true); stopLayer->setOpacity(GLubyte(255*0.75)); stopLayer->setScale(0.5); addChild(stopLayer,8); stopLayer->setVisible(false); auto node = CSLoader::createNode("GameStop.csb"); stopLayer->addChild(node); auto backButton = dynamic_cast<ui::Button*>(node->getChildByName("backButton")); backButton->addClickEventListener([=](Ref* pSender){ hideLayer(); }); auto restartButton = dynamic_cast<ui::Button*>(node->getChildByName("restartButton")); restartButton->addClickEventListener([=](Ref* pSender){ Hero::heroLife = 10; ShareData::getInstance()->heroScore = 0; Director::getInstance()->replaceScene(MainScene::createScene()); Director::getInstance()->resume(); }); auto quitButton = dynamic_cast<ui::Button*>(node->getChildByName("quitButton")); quitButton->addClickEventListener([=](Ref* pSender){ Director::getInstance()->replaceScene(StartScene::createScene()); Director::getInstance()->resume(); }); listener = EventListenerTouchOneByOne::create(); listener->onTouchBegan = [=](Touch* touch, Event* e){ if( stopButton->getBoundingBox().containsPoint(touch->getLocation())){ showLayer(); }else if( leftButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strLeftButtonDown); }else if( rightButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strRightButtonDown); }else if( moveButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strQuickMove); }else if( hitButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strHeroShoot); }else if( jumpButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strJumpButtonDown); } return true; }; listener->onTouchEnded = [=](Touch* touch, Event* e){ if( leftButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strLeftButtonUp); }else if( rightButton->getBoundingBox().containsPoint(touch->getLocation())){ NotificationCenter::getInstance()->postNotification(strRightButtonUp); } }; listener->setSwallowTouches(true); _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,this); dieLayer = Layer::create(); addChild(dieLayer); dieLayer->setVisible(false); auto dieSprite = Sprite::create("die.png"); dieSprite->setPosition(vSize.width/2,vSize.height/2+60); dieLayer->addChild(dieSprite); ui::Button* restart = ui::Button::create("continue.png"); restart->setPosition(Vec2(vSize.width/2,vSize.height/2-60)); restart->addClickEventListener([=](Ref* pSender){ Hero::heroLife = 10; ShareData::getInstance()->heroScore = 0; ShareData::getInstance()->rankScore = 0; MainScene::level = 1; Director::getInstance()->replaceScene(MainScene::createScene()); SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); Director::getInstance()->resume(); }); dieLayer->addChild(restart); }