void NovelScene::makeSelectSpriteButton(string str1, int next1Id, string str2, int next2Id) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCMenu* pMenu = (CCMenu*) this->getChildByTag(kTag_MenuSelect); if (pMenu) { pMenu->setVisible(true); MenuItemSelectLabelSprite* menuSprite1 = (MenuItemSelectLabelSprite*) pMenu->getChildByTag(kTag_MenuSelect1); menuSprite1->setNovelText(str1.c_str(), next1Id); MenuItemSelectLabelSprite* menuSprite2 = (MenuItemSelectLabelSprite*) pMenu->getChildByTag(kTag_MenuSelect2); menuSprite2->setNovelText(str2.c_str(), next2Id); } else { //선택지1 MenuItemSelectLabelSprite* menuSprite1 = MenuItemSelectLabelSprite::createWithLabelSprite("menu_button.png", str1.c_str(), "Arial", BASE_FONT_SIZE, ccBLACK, ccBLUE, ccRED, next1Id, this, menu_selector(NovelScene::menuSelectCallback)); menuSprite1->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.55)); menuSprite1->setTag(kTag_MenuSelect1); menuSprite1->setZOrder(kZOrder_MenuSelect); //선택지2 MenuItemSelectLabelSprite* menuSprite2 = MenuItemSelectLabelSprite::createWithLabelSprite("menu_button.png", str2.c_str(), "Arial", BASE_FONT_SIZE, ccBLACK, ccBLUE, ccRED, next2Id, this, menu_selector(NovelScene::menuSelectCallback)); menuSprite2->setPosition(ccp(winSize.width * 0.5, winSize.height * 0.45)); menuSprite2->setTag(kTag_MenuSelect2); menuSprite2->setZOrder(kZOrder_MenuSelect); //메뉴 작성 pMenu = CCMenu::create(menuSprite1, menuSprite2, NULL); pMenu->setPosition(CCPointZero); this->addChild(pMenu, kZOrder_MenuSelect, kTag_MenuSelect); } }
void RPGMapSceneLayer::ccTouchEnded(CCTouch* touch, CCEvent* event) { if(this->m_touchedDialogNPC) { CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); CCPoint point = touch->getLocation(); point = bgMap->convertToNodeSpace(point); if(this->m_touchedDialogNPC->boundingBox().containsPoint(point)) { this->m_touchedDialogNPC->stopAutoMove(); //暂时停止自动移动 this->enabledControl(false); string content = this->m_touchedDialogNPC->m_content->getCString(); RPGMapDialogLayer *dialogLayer = RPGMapDialogLayer::create(this->m_stringList, &this->m_db, this->m_touchedDialogNPC); this->addChild(dialogLayer); CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu); mainMenu->setVisible(false); //player和NPC互相对着 RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); switch (this->m_dialogDirection) { case kRPGMapSceneLayerDialogDirectionUp: { player->setDirection(kRPGMapRoleSpriteDirectionDown); this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionUp); } break; case kRPGMapSceneLayerDialogDirectionDown: { player->setDirection(kRPGMapRoleSpriteDirectionUp); this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionDown); } break; case kRPGMapSceneLayerDialogDirectionLeft: { player->setDirection(kRPGMapRoleSpriteDirectionRight); this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionLeft); } break; case kRPGMapSceneLayerDialogDirectionRight: { player->setDirection(kRPGMapRoleSpriteDirectionLeft); this->m_touchedDialogNPC->setDirection(kRPGMapRoleSpriteDirectionRight); } break; default: break; } } } this->m_touchedDialogNPC = NULL; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionNone; }
bool HSGameFrisbee::init() { CCMenu* pSetingMenu = HS_FIND_UI_MENU("UI_HEbinggaojiduchangxin_Xitongtuibiao_01"); //ÒôЧ HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_0",this,HSGameFrisbee::Call_Muisc); //ÒôÀÖ HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_1",this,HSGameFrisbee::Call_Sound); //°ïÖú HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_2",this,HSGameFrisbee::Call_Help); //¹ØÓÚ HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_3",this,HSGameFrisbee::Call_About); for (int i=0;i<50;++i) { CCString* ui = CCString::createWithFormat("UI_HEbinggaojiduchangxin_shezhi_%d",i); CCMenu* otherMenu = HS_FIND_UI_MENU(ui->getCString()); if (!otherMenu) { continue; } _MenuItem tempMenuItem; tempMenuItem.pNode = otherMenu; tempMenuItem.srcPos = pSetingMenu->getPosition(); tempMenuItem.endPos = otherMenu->getPosition(); m_menuList.push_back(tempMenuItem); otherMenu->setPosition(pSetingMenu->getPosition()); otherMenu->setVisible(false); } return true; }
void RPGMapSceneLayer::joystickEndedFunc() { CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu); mainMenu->setVisible(true); player->stopMove(); }
void GameMain::setover() { CCMenu* pMenu = (CCMenu *)this->getChildByTag(25); pMenu->setVisible(true); pMenu->setEnabled(true); gameover->setVisible(true); gameover->setScale(0); pMenu->setScale(0); pMenu->runAction(CCScaleTo::create(0.5,1)); gameover->runAction(CCScaleTo::create(0.5,0.5)); isover = true; }
void GameMainLayer::setOver() { //游戏结束 CCMenu *pMenu = (CCMenu *)this->getChildByTag(25); pMenu->setVisible(true); pMenu->setEnabled(true); pMenu->setScale(0); pMenu->runAction(CCScaleTo::create(0.5f, 1)); gameOver->setVisible(true); gameOver->setScale(0); gameOver->runAction(CCScaleTo::create(0.5f, 0.5f)); this->isOver = true; }
void RPGMapSceneLayer::enabledControl(bool enabled) { CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu); OzgJoystickLayer *joystick = (OzgJoystickLayer*)this->getChildByTag(kRPGMapSceneLayerTagJoystick); if(enabled) { CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true); joystick->active(); mainMenu->setVisible(true); } else { CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this); joystick->inactive(); mainMenu->setVisible(false); } }
void GamePan::showHideConfirmPad(bool isShow) { CCLayerColor* pBaseNode = dynamic_cast<CCLayerColor*>(m_pCcbNode->getChildByTag(kTagGamePanConfirmPad)); pBaseNode->setVisible(isShow); CCLabelTTF* pText = dynamic_cast<CCLabelTTF*>(pBaseNode->getChildByTag(1)); pText->setVisible(!_isPlayer); CCMenu* pMenu = dynamic_cast<CCMenu*>(pBaseNode->getChildByTag(0)); pMenu->setVisible(isShow && _isPlayer); pMenu->setTouchPriority(-1000); if(pMenu) { CCMenuItemImage* btn = dynamic_cast<CCMenuItemImage*>(pMenu->getChildByTag(kTagGamePanConfirmPadOkBtn)); btn->setTarget(this,menu_selector(GamePan::ConfirmBtnCallback)); btn = dynamic_cast<CCMenuItemImage*>(pMenu->getChildByTag(kTagGamePanConfirmPadCancelBtn)); btn->setTarget(this,menu_selector(GamePan::ConfirmBtnCallback)); } }
bool GameMainLayer::init() { if (!CCLayer::init()) return false; CCSize size = CCDirector::sharedDirector()->getVisibleSize(); CCPoint originPoint = CCDirector::sharedDirector()->getVisibleOrigin(); map = new GameObjMap(); map->setAnchorPoint(ccp(0, 1)); map->setPosition(ccpSub(ccp(0, size.height), originPoint)); this->addChild(map, 0); hero = new GameObjHero(); hero->setScale(0.5f); hero->setPosition(ccpAdd(ccp(100, 160), originPoint)); this->addChild(hero, 1); gameMark = new GameMark(); this->addChild(gameMark, 4); //游戏结束 gameOver = CCSprite::create("gameover.png"); gameOver->setScale(0.5f); gameOver->setPosition(ccp(size.width/2, size.height/2 + 70)); gameOver->setVisible(false); this->addChild(gameOver, 5); //菜单项 CCMenuItemImage *pCloseItem = CCMenuItemImage::create("back.png", "back.png", this, menu_selector(GameMainLayer::menuBackCallback)); pCloseItem->setPosition(ccp(size.width/2, size.height/2 - 50)); pCloseItem->setScale(0.5f); CCMenu *pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition(CCPointZero); this->addChild(pMenu, 5, 25); pMenu->setVisible(false); pMenu->setEnabled(false); this->isOver = false; this->scheduleUpdate(); return true; }
void HSEmailSystemLayer::Load() { CCSprite* pBackground = HSCCSprite::create("Image/BEIJING.png"); pBackground->setPosition(HSBase::GetTemplateScreenCentre()); this->addChild(pBackground); HSTool::SetNodeFilldScreen(pBackground); HSReadUI::ShareReadUI()->ReadUI("Image/EmailSystem.data","Image/",this); CCSprite* pMoneyFrame = HS_FIND_UI_PANEL_SPRITE("UI_Jinbidiandikuang","Jinbidiandikuang"); CCTexture2D* pMoneyTexture = CCTextureCache::sharedTextureCache()->addImage("Image/moneyNumber.png"); m_pMoney = CCLabelAtlas::create("0","Image/moneyNumber.png",pMoneyTexture->getPixelsWide() / 11,pMoneyTexture->getPixelsHigh(),'0'); m_pMoney->setAnchorPoint(HS_ANCHOR_CENTER); m_pMoney->setPosition(HS_SizeHalf_Point(pMoneyFrame->getContentSize())); pMoneyFrame->addChild(m_pMoney); CCSprite* pEmailSystemFrame = HS_FIND_UI_PANEL_SPRITE("UI_FriendFrame","gerenxinxilanfanwei"); m_pEmailListView = HSEmailListVeiw::create(pEmailSystemFrame->getContentSize(),CCSizeMake(505,100),HS_GAME_CACHE()->m_EmailResponse.emaillist_size()); CCPoint pos = CCPointZero; pos.x = -pEmailSystemFrame->getContentSize().width / 2.f - 15.f; pos.y = pEmailSystemFrame->getPosition().y - pEmailSystemFrame->getContentSize().height / 2.f - 20.f; m_pEmailListView->setPosition(pos); pEmailSystemFrame->getParent()->addChild(m_pEmailListView,1000); m_pEmailListView->reloadData(); HS_SET_MENU_TARGET("UI_fh_01",this,HSEmailSystemLayer::Call_Back); HS_SET_MENU_TARGET("UI_Goumaijinbianniu_01",this,HSEmailSystemLayer::Call_Shop); if (HS_GAME_CACHE()->m_EmailResponse.emaillist_size() == 0) { CCMenu* pMenu = HS_FIND_UI_MENU("UI_quanbulingqu"); pMenu->setVisible(false); }else{ HS_SET_MENU_TARGET("UI_quanbulingqu",this,HSEmailSystemLayer::Call_AllRevc); } this->schedule(schedule_selector(HSEmailSystemLayer::Updata)); }
bool RPGMapSceneLayer::ccTouchBegan(CCTouch* touch, CCEvent* event) { CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap); RPGMapRoleSprite *player = (RPGMapRoleSprite*)bgMap->getChildByTag(kRPGMapSceneLayerTagPlayer); //循环判断点击了哪一个NPC,如果有点中则m_isTouchedNPC为true for (int i = 0; i < bgMap->getChildren()->count(); i++) { CCObject *item = bgMap->getChildren()->objectAtIndex(i); if(dynamic_cast<RPGMapRoleSprite*>(item) != NULL) { RPGMapNPCRoleSprite *npc = (RPGMapNPCRoleSprite*)item; if(npc->m_type == kRPGMapRoleSpriteTypeNPC) { //判断player是否存在该NPC的四个方向(距离为一格),存在则为true bool exist = false; if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(0, GAME_TMX_ROLE_HEIGHT)))) { //上 exist = true; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionUp; } else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(0, -GAME_TMX_ROLE_HEIGHT)))) { //下 exist = true; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionDown; } else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(-GAME_TMX_ROLE_WIDTH, 0)))) { //左 exist = true; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionLeft; } else if(player->getPosition().equals(ccpAdd(npc->getPosition(), ccp(GAME_TMX_ROLE_WIDTH, 0)))) { //右 exist = true; this->m_dialogDirection = kRPGMapSceneLayerDialogDirectionRight; } if(exist) { CCPoint point = touch->getLocation(); point = bgMap->convertToNodeSpace(point); if(npc->boundingBox().containsPoint(point)) { this->m_touchedDialogNPC = npc; break; } } } } } //如果是点中了NPC则进入ccTouchEnded的处理 if(this->m_touchedDialogNPC) return true; else { //传入到摇杆的事件处理 CCMenu *mainMenu = (CCMenu*)bgMap->getChildByTag(kRPGMapSceneLayerTagMainMenu); mainMenu->setVisible(false); return false; } }