void PopupLayer::backgroundFinish(){ Size winSize = CCDirector::getInstance()->getWinSize(); Point pCenter = Point(winSize.width / 2, winSize.height / 2); // 添加按钮,并设置其位置 this->addChild(getMenuButton()); float btnWidth = m_dialogContentSize.width / (getMenuButton()->getChildrenCount() + 1); Vector<Node*> vector = getMenuButton()->getChildren(); Ref* pObj = NULL; int i = 0; for(Node* pObj : vector){ Node* node = dynamic_cast<Node*>(pObj); node->setPosition(Point( winSize.width / 2 - m_dialogContentSize.width / 2 + btnWidth * (i + 1), winSize.height / 2 - m_dialogContentSize.height / 3)); i++; } // 显示对话框标题 if (getLabelTitle()){ getLabelTitle()->setPosition(ccpAdd(pCenter, ccp(0, m_dialogContentSize.height / 2 - 35.0f))); this->addChild(getLabelTitle()); } // 显示文本内容 if (getLabelContentText()){ CCLabelTTF* ltf = getLabelContentText(); ltf->setPosition(ccp(winSize.width / 2, winSize.height / 2)); ltf->setDimensions(CCSizeMake(m_dialogContentSize.width - m_contentPadding * 2, m_dialogContentSize.height - m_contentPaddingTop)); ltf->setHorizontalAlignment(kCCTextAlignmentLeft); this->addChild(ltf); } }
void PopupLayer::onEnter(){ CCLayer::onEnter(); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2); CCSize contentSize; // 设定好参数,在运行时加载 if (getContentSize().equals(CCSizeZero)) { getSpriteBackGround()->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(getSpriteBackGround(), 0, 0); contentSize = getSpriteBackGround()->getTexture()->getContentSize(); } else { extension::Scale9Sprite *background = getSprite9BackGround(); background->setContentSize(getContentSize()); background->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(background, 0, 0); contentSize = getContentSize(); } // 添加按钮,并设置其位置 this->addChild(getMenuButton()); float btnWidth = contentSize.width / (getMenuButton()->getChildrenCount() + 1); Vector<cocos2d::CCNode*> array = getMenuButton()->getChildren(); CCObject* pObj = NULL; int i = 0; while(i<array.size()) { CCNode* node = array.at(i); node->setPosition(ccp( winSize.width / 2 - contentSize.width / 2 + btnWidth * (i + 1), winSize.height / 2 - contentSize.height / 5)); i++; } // 显示对话框标题 if (getLabelTitle()){ getLabelTitle()->setPosition(ccpAdd(pCenter, ccp(0, contentSize.height / 2 - 35.0f))); this->addChild(getLabelTitle()); } // 显示文本内容 if (getLabelContentText()){ CCLabelTTF* ltf = getLabelContentText(); ltf->setPosition(ccp(winSize.width / 2, winSize.height / 2)); ltf->setDimensions(CCSizeMake(contentSize.width - m_contentPadding * 2, contentSize.height - m_contentPaddingTop)); ltf->setHorizontalAlignment(kCCTextAlignmentLeft); this->addChild(ltf); } // 弹出效果 CCAction* popupLayer = CCSequence::create(CCScaleTo::create(0.0, 0.0), CCScaleTo::create(0.06, 1.05), CCScaleTo::create(0.08, 0.95), CCScaleTo::create(0.08, 1.0), NULL); this->runAction(popupLayer); }
//设置层的内容 void GRPopLayer::setContent() { CCDictionary* pDict = CCDictionary::createWithContentsOfFile("data.xml"); std::string str = pDict->valueForKey("PopLayerText")->getCString(); CCLabelTTF * content = CCLabelTTF::create(str,"",24); content->setPosition(ccp(m_size.width/2,m_size.height/2)); //设置ttf的文本域 content->setDimensions(CCSize(this->m_size.width-60,this->m_size.height-100)); //设置ttf的水平对齐方式 content->setHorizontalAlignment(kCCTextAlignmentLeft); m_bgSprite->addChild(content); }
void BaseScene::addTipBoard(const char* tip) { CCSprite* tipBoard = CCSprite::createWithSpriteFrameName("tip_board"); tipBoard->setAnchorPoint(ccp(0.0f, 1.0f)); //tipBoard->cocos2d::CCNode::setPosition(SCALED_VALUE(12.0f), SCALED_VALUE(368.0f)); PlaceNode(tipBoard, 0.02, 0.764); this->addChild(tipBoard); CCLabelTTF* tipLabel = CCLabelTTF::create(tip, "Arial", SCALED_VALUE(20.0f)); tipLabel->setColor(ccc3(33, 33, 33)); tipLabel->setAnchorPoint(ccp(0.5f, 1.0f)); tipLabel->setDimensions(CCSizeMake(tipBoard->getContentSize().width * 0.8, tipBoard->getContentSize().height * 0.8)); float py = 0.0f; py = tipBoard->getPositionY(); py = py - SCALED_VALUE(127.0f); tipLabel->setPositionY(py); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) tipBoard->setScaleY(1.20f); if (AppDelegate::SCREEN_HEIGHT > 400.0f) { tipLabel->setPositionY(py + SCALED_VALUE(10.0f)); } else { tipLabel->setPositionY(py - SCALED_VALUE(5.0f)); } #else //PlaceNode(tipLabel, 0.04, 0.55); #endif //tipLabel->setPositionY(py); float pX = tipBoard->getPositionX() + tipBoard->getContentSize().width/2; tipLabel->setPositionX(pX); this->addChild(tipLabel); }
void hctooltip::setData(int tempid) { this->removeAllChildren(); configGoodsItem * item = CData::getCData()->getConfigOfGoods(tempid); const ccColor3B color2 = {160,220,220}; CCSprite* sp; char itemicon[40]=""; if(item->icon >=6000 && item->icon<= 6056) { sprintf(itemicon, "qs_%d.png",item->icon); sp = CCSprite::create(itemicon); sp->setScale(0.19); sp->setAnchorPoint(ccp(0, 1)); sp->setPosition(ccp(10, size.height - 10)); this->addChild(sp); } else { sprintf(itemicon, "item_%d.png",item->icon); sp = CCSprite::create(itemicon); sp->setAnchorPoint(ccp(0, 1)); sp->setPosition(ccp(10, size.height - 10)); this->addChild(sp); } CCLabelTTF * labname = CCLabelTTF::create(item->name.c_str(),"hycc.ttf", 20); labname->setPosition(ccp(size.width/2 +55, size.height - 50)); labname->setColor(color2); this->addChild(labname); CCLabelTTF* labdesc = CCLabelTTF::create(item->des.c_str(), "hycc.ttf", 20); labdesc->setDimensions(CCSizeMake(size.width-20, 0)); labdesc->setHorizontalAlignment(kCCTextAlignmentLeft); labdesc->setPosition(ccp(size.width/2, size.height - 200)); labdesc->setColor(color2); this->addChild(labdesc); }
void BossLotteryNotice::initContent() { CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/fightUI/gainGold.plist"); CCSprite *bg = CCSprite::createWithSpriteFrameName("gainGold_bg.png"); addChild(bg); CCSprite *title = CCSprite::createWithSpriteFrameName("gainGold_title.png"); bg->addChild(title); title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 30)); CCLabelTTF *content = CCLabelTTF::create(); content->setFontSize(24); content->setColor(ccGREEN); bg->addChild(content); content->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 30)); content->setDimensions(CCSizeMake(bg->getContentSize().width - 40, 200)); content->setVerticalAlignment(kCCVerticalTextAlignmentCenter); content->setHorizontalAlignment(kCCTextAlignmentCenter); content->setString(CCString::createWithFormat("恭喜获得击杀将领%d倍奖励",multiple)->getCString()); }
void HelpScene::buildScene() { // Call super build scene. BaseScene::buildScene(); BaseScene::addTipBoard("Do you know that EziByte team provides you personalize support for all your queries? Just try sending email to them at [email protected]"); buildHeader(2, "Help", "Get all the help you need."); const char* helpText = "What is EziSocial?\n\nEziSocial is a powerful social networking plugin designed for Cocos2D-X platform to meet the social networking capabilities required in a game. The tool is written in Java, Objective-C and C++. EziSocial plugin uses common development code for both Android and iOS Cocos2D-x project. So, there is no duplicity of code and you need not to worry about portability issue at all.\n\nFor more details you can visit our website. http:://www.ezibyte.com"; CCLabelTTF* helpTextLabel = CCLabelTTF::create("", "Arial", SCALED_VALUE(20.0f)); helpTextLabel->setDimensions(CCSizeMake(AppDelegate::SCREEN_WIDTH * 0.60, AppDelegate::SCREEN_HEIGHT * 0.72)); helpTextLabel->setString(helpText); this->addChild(helpTextLabel); helpTextLabel->setAnchorPoint(ccp(0.0, 1.0)); helpTextLabel->setVerticalAlignment(kCCVerticalTextAlignmentTop); float py = 1 - (1 - 0.764); PlaceNode(helpTextLabel, 0.38, py); }
CCTableViewCell* RequestList::tableCellAtIndex(CCTableView *table, unsigned int idx) { int index = idx; EziFBIncomingRequest* fbRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(index); EziFacebookFriend* sender = fbRequest->getSender(); const char* senderName = sender->getName(); // Create the fancy test. EziSocialWrapperNS::FB_REQUEST::TYPE requestType = fbRequest->getRequestType(); std::string messageToDisplay = ""; switch (requestType) { case EziSocialWrapperNS::FB_REQUEST::REQUEST_INVITE: messageToDisplay.append(senderName).append(" has sent invitation to you."); break; case EziSocialWrapperNS::FB_REQUEST::REQUEST_GIFT: messageToDisplay.append(senderName).append(" has sent gift to you."); break; case EziSocialWrapperNS::FB_REQUEST::REQUEST_CHALLENGE: messageToDisplay.append(senderName).append(" has challenged to you."); break; default: messageToDisplay.append("Unknown message"); break; } // Means users have already used this request. bool requestConsumed = fbRequest->isConsumed(); CCSprite* profilePic = NULL; ccColor4B bgColor = ccc4(20, 0, 40, 255); if (requestConsumed == false) { bgColor = ccc4(50, 50, 20, 255); } // Build the table cell. CCTableViewCell *cell = table->dequeueCell(); if (cell == NULL) { cell = new CCTableViewCell(); cell->autorelease(); // Create the back layer of the cell. CCLayerColor* colorLayer = CCLayerColor::create(bgColor, SCREEN_WIDTH, CELL_HEIGHT); colorLayer->setTag(BACKGROUND_TAG); cell->addChild(colorLayer); // Get the sender profile picture path. Create it if path is available. if (sender != NULL && strcmp(sender->getPhotoPath(), "") != 0) { const char* picPath = sender->getPhotoPath(); profilePic = CCSprite::create(picPath); } else { profilePic = CCSprite::create(FB_DEFAULT_PHOTO); } // Add the profile pic to the cell row. profilePic->setAnchorPoint(ccp(0, 0.5)); profilePic->setPosition(ccp(20, CELL_HEIGHT/2)); cell->addChild(profilePic); profilePic->setTag(FRIEND_PHOTO_TAG); // Set the message. CCLabelTTF *messageLabel = CCLabelTTF::create(messageToDisplay.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE); messageLabel->setAnchorPoint(ccp(0, 0.5)); messageLabel->setPosition(ccp(20 + 20 + profilePic->getContentSize().width, CELL_HEIGHT/2)); messageLabel->setTag(REQUEST_MESSAGE_LABEL_TAG); messageLabel->setDimensions(CCSizeMake(SCREEN_WIDTH - (profilePic->getContentSize().width * 2) - 60, CELL_HEIGHT-5)); messageLabel->setHorizontalAlignment(kCCTextAlignmentLeft); cell->addChild(messageLabel); CCMenuItemImage* constumeItemButton = NULL; constumeItemButton = CCMenuItemImage::create("use.png", "use_pressed.png"); constumeItemButton->setTag(idx); constumeItemButton->setTarget(this, menu_selector(RequestList::useItem)); constumeItemButton->setScale(SCALE_FACTOR * 0.8); constumeItemButton->setTag(FRIEND_CONSUME_BUTTON_TAG); CCMenu* consumeMenu = CCMenu::create(constumeItemButton, NULL); consumeMenu->setTag(FRIEND_CONSUME_MENU_TAG); consumeMenu->setPosition(ccp(SCREEN_WIDTH - (constumeItemButton->getContentSize().width*SCALE_FACTOR*0.4), (CELL_HEIGHT - (constumeItemButton->getContentSize().height)*SCALE_FACTOR*0.4))); cell->addChild(consumeMenu); } else { // Refresh the cell data based upon idx. // 1. Refresh the profile picture. CCSprite* cellProfilePic = (CCSprite*)cell->getChildByTag(FRIEND_PHOTO_TAG); if (strcmp("", sender->getPhotoPath()) != 0 ) { const char* picPath = sender->getPhotoPath(); profilePic = CCSprite::create(picPath); } else { profilePic = CCSprite::create(FB_DEFAULT_PHOTO); } cellProfilePic->setTexture(profilePic->getTexture()); // Update the message Label. CCLabelTTF *messageLabel = (CCLabelTTF*)cell->getChildByTag(REQUEST_MESSAGE_LABEL_TAG); messageLabel->setString(messageToDisplay.c_str()); CCMenu* consumeMenu = (CCMenu*)cell->getChildByTag(FRIEND_CONSUME_MENU_TAG); CCArray* children = consumeMenu->getChildren(); if (children) { CCMenuItemImage* consumenButton = (CCMenuItemImage*)children->objectAtIndex(0); if (consumenButton) { consumenButton->setTag(index); } else { CCLOG("No Consume Button"); } } CCLayerColor* bgLayer = (CCLayerColor*)cell->getChildByTag(BACKGROUND_TAG); bgLayer->setColor(ccc3(bgColor.r, bgColor.g, bgColor.b)); } return cell; }
void LevelScene::createLevelsLayer() { CCArray *pLayers = CCArray::create(); CCArray *pLevels = m_pKategoria->getPantailak(); int numLevels = pLevels->count(); int numberPages = numLevels / 4; if (numLevels % 4 > 0) { numberPages++; } int cont = 0; for (int i = 1; i <= numberPages; i++) { CCLayer *pContainer = CCLayer::create(); CCLayer *pContentLayer = CCLayer::create(); CCSize contentSize = CCSizeMake(500, 490); CCPoint contentPos = ccp(VisibleRect::center().x - contentSize.width/2, VisibleRect::center().y - contentSize.height/2); pContentLayer->setContentSize(contentSize); pContentLayer->setPosition(contentPos); CCPoint texturePosition[] = {ccp(122, 369), ccp(372, 369), ccp(122, 149), ccp(372, 149)}; CCPoint labelPosition[] = {ccp(125, 250), ccp(375, 250), ccp(125, 30), ccp(375, 30)}; int numberRows = numLevels - (4 * (i-1)); if (numberRows > 4) numberRows = 4; for(int j = 1; j <= numberRows; j++) { LevelModel *pLevel = (LevelModel*) pLevels->objectAtIndex(cont); std::string imageName = CCFileUtils::sharedFileUtils()->getWriteablePath().append(pLevel->getList()); CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage("borde.png"); SpriteButton *pLevelButton = SpriteButton::create(pTexture ,this, callfuncO_selector(LevelScene::levelClicked)); pLevelButton->setPosition(texturePosition[j-1]); pLevelButton->setTag(cont); pTexture = CCTextureCache::sharedTextureCache()->addImage(imageName.c_str()); CCSprite *pImageBorder = CCSprite::createWithTexture(pTexture); //pImageBorder->setAnchorPoint(ccp(0, 0)); pImageBorder->setScale(imageScale); pImageBorder->setPosition(ccp(87, 95)); pLevelButton->addChild(pImageBorder); pContentLayer->addChild(pLevelButton); CCLabelTTF *pLabel = CCLabelTTF::create(pLevel->getIzena(), fontList[0], 22.0); pLabel->setPosition(labelPosition[j-1]); pLabel->setColor(ccc3(63, 62, 62)); pLabel->setDimensions(CCSizeMake(257, 50)); pContentLayer->addChild(pLabel); cont++; } pContainer->addChild(pContentLayer); pLayers->addObject(pContainer); } CCScrollLayer *pScrollLayer = CCScrollLayer::nodeWithLayers(pLayers, 0); pScrollLayer->setPagesIndicatorPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y + 70)); pScrollLayer->setDelegate(this); pScrollLayer->moveToPage(0); addChild(pScrollLayer); }
int Bitmap::handler_method_drawtext( int ptr1,void* ptr2 ) { Bitmap* bitmap = (Bitmap*)ptr1; if (NULL==bitmap->p->m_emuBitmap) return -1; bool firstdraw = false; CCRenderTexture* fontRender = (CCRenderTexture*)bitmap->p->m_fontRender; if (NULL==fontRender) { fontRender = CCRenderTexture::create(bitmap->p->m_width,bitmap->p->m_height); bitmap->getEmuBitmap()->addChild(fontRender); fontRender->setPosition(ccp(bitmap->p->m_width/2,bitmap->p->m_height/2)); bitmap->p->m_fontRender = fontRender; fontRender->retain(); firstdraw = true; //fontRender->getSprite()->getTexture()->setAliasTexParameters(); } DrawtextStruct* ptr2struct = (DrawtextStruct*)ptr2; string tmpdrawchar = ptr2struct->str; // int checknum = atoi(tmpdrawchar.c_str()); // if (checknum!=0) // { // char tmp[20]={0}; // sprintf(tmp,"%d",checknum); // tmpdrawchar = tmp; // } CCLabelTTF* label = CCLabelTTF::create(tmpdrawchar.c_str(),ptr2struct->font->getName(),ptr2struct->font->getSize()); //label->getTexture()->setAliasTexParameters(); if (ptr2struct->font) { Font* f = ptr2struct->font; label->setFontName(f->getName()); label->setFontSize(f->getSize()); label->setColor(ccc3(f->getColor()->red*f->getColor()->alpha/255, f->getColor()->green*f->getColor()->alpha/255, f->getColor()->blue*f->getColor()->alpha/255)); //label->setOpacity(f->getColor()->alpha); } label->setAnchorPoint(ccp(0,1)); label->setDimensions(CCSizeMake(ptr2struct->rect.w,ptr2struct->rect.h)); label->setPosition(ccp(ptr2struct->rect.x,rgss_y_to_cocos_y(ptr2struct->rect.y,bitmap->p->m_height))); label->setVerticalAlignment(kCCVerticalTextAlignmentCenter); if (ptr2struct->align == Bitmap::Center) label->setHorizontalAlignment(kCCTextAlignmentCenter); else if(ptr2struct->align == Bitmap::Right) label->setHorizontalAlignment(kCCTextAlignmentRight); else if (ptr2struct->align == Bitmap::Left) label->setHorizontalAlignment(kCCTextAlignmentLeft); // CCLayerColor* masklayer = CCLayerColor::create(ccc4(255,255,255,255)); // masklayer->setContentSize(label->getContentSize()); // masklayer->setPosition(ccp(ptr2struct->rect.x,rgss_y_to_cocos_y(ptr2struct->rect.y,bitmap->m_height)-masklayer->getContentSize().height)); // ccBlendFunc fun = {GL_ZERO,GL_ZERO}; // masklayer->setBlendFunc(fun); fontRender->begin(); //masklayer->visit(); label->visit(); fontRender->end(); label->release(); delete ptr2struct; return 0; }
void TargetLayer::makeTargets(int countTargets, cocos2d::CCArray *targetLetters) { this->removeAllChildrenWithCleanup(true); targets->removeAllObjects(); int targetCount = 0; int rows =(countTargets + DEFAULT_COLS - 1) / DEFAULT_COLS; int cols = countTargets > DEFAULT_COLS?DEFAULT_COLS:countTargets; float targetSpaceX = (winSize.width - (2.0 * TARGET_AREA_PAD)) / cols; for (int rowIndex = 0; rowIndex < rows; rowIndex++) { // Check if more targets than letters. Just stop making targets. if (targetCount >= targetLetters->count() && targetLetters->count() != 0) { break; } cols = (countTargets - targetCount) > DEFAULT_COLS?DEFAULT_COLS:(countTargets - targetCount); targetSpaceX = (winSize.width - (2.0 * TARGET_AREA_PAD)) / cols; CCLog("Cols is %d", cols); CCLog("targetSpaceX is %f", targetSpaceX); // Calculate the Y position float yPos = winSize.height - TARGET_AREA_Y_OFFSET - 120 * SCALEY * rowIndex; for (int colIndex = 0; colIndex < cols ; colIndex++) { // Calculate the X position float xPos = (colIndex * targetSpaceX) + targetSpaceX * 0.5 + TARGET_AREA_PAD; // Add Targret Sprite CCSprite* targetSprite = CCSprite::create(getResPath(GAME_TARGET_IMG)); targetSprite->setPosition(ccp(xPos, yPos)); targetSprite->setScale(SCALE * 1.2); this->addChild(targetSprite, 0); // Add the target sprite targets->addObject(targetSprite); string fontName; bool fontType = GameOptions::getInstance()->getFontType(); if (fontType) { fontName = FONT_LETTER_NOR; }else { fontName = FONT_LETTER_CUR; } CCLabelTTF* letterSprite; if (targetLetters->count() > 0) { // Get the next letter for the target CCInteger* numberObj = (CCInteger*)targetLetters->objectAtIndex(targetCount); int letterIndex = numberObj->getValue(); targetSprite->setTag(TAG_TARGET + letterIndex); // Make the letter sprite(Label) on the target. Font size is the target width string letterString = AlphaBetUtils::getInstance()->getKeyMapFont(letterIndex); letterSprite = CCLabelTTF::create(letterString.c_str(), fontName.c_str(), targetSprite->getContentSize().width * 0.6); letterSprite->setVerticalAlignment(kCCVerticalTextAlignmentCenter); letterSprite->setHorizontalAlignment(kCCTextAlignmentCenter); letterSprite->setDimensions(CCSize(targetSprite->getContentSize().width, targetSprite->getContentSize().width)); }else { // Fill-in an Empty Target letterSprite = CCLabelTTF::create("", fontName.c_str(), targetSprite->getContentSize().width); } letterSprite->setColor(letterColor); CCPoint centerPoint = ccp(targetSprite->getContentSize().width * 0.5, targetSprite->getContentSize().height * 0.5); letterSprite->setPosition(centerPoint); targetSprite->addChild(letterSprite, 10, TAG_LETTER); targetCount++; } } CCLOG("Targets Count is %d", targets->count()); }
bool StoryWorld::init() { if ( !CCLayer::init() ) { return false; } char theName[10][11]={"","穆婧:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"}; char play[20] = SCRIPT_PATH; current=sGlobal->mapState->storyCnt+'0'; play[SCRIPT_PATH_LEN] = current; reader.ReadFileWithFullPath(CCFileUtils::sharedFileUtils()->fullPathForFilename(play)); this->setTouchEnabled(true); CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); char bg_name[30] = "" ; char bg_num[4]=""; sprintf(bg_num, "%c00", current); sprintf(bg_name, BGNAME_IMG_PATH, bg_num); CCSprite *pBackground = CCSprite::createWithTexture(GET_TEXTURE(bg_name)); //CCSprite* pBackground = CCSprite::create(bg_name); pBackground->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); pBackground->setScale(1); pBackground->setTag(108); addChild(pBackground, 0); CCSprite* dialogBox = CCSprite::create(DUIHUAKUANG_IMG_PATH); dialogBox->setPosition(ccp(visibleSize.width/2, dialogBox->getContentSize().height/2)); dialogBox->setOpacity(220); addChild(dialogBox,1); CCLabelTTF* pName = CCLabelTTF::create(theName[0], "Heiti SC", 40); pName->setTag(101); pName->setPosition(ccp(pName->getContentSize().width/2, dialogBox->getContentSize().height - 2 * pName->getContentSize().height)); pName->setAnchorPoint(CCPointZero); addChild(pName, 1); CCLabelTTF* pLabel = CCLabelTTF::create("Click to Start", "Heiti SC", 40); pLabel->setTag(100); pLabel->setPosition(ccp(40, origin.y + dialogBox->getContentSize().height - 3.4 * pLabel->getContentSize().height)); pLabel->setAnchorPoint(CCPointZero); pLabel->setDimensions(CCSizeMake(1100, 0)); pLabel->setHorizontalAlignment(kCCTextAlignmentLeft); addChild(pLabel, 1); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(PLIST_IMG_PATH); CCSpriteBatchNode *spriteBatch = CCSpriteBatchNode::createWithTexture(GET_TEXTURE(VDRAWING_IMG_PATH)); spriteBatch->setTag(102); addChild(spriteBatch, 0); spriteBatch->setPosition(CCPointZero); CCSprite *leftSprite=CCSprite::createWithSpriteFrameName("me_1.png"); leftSprite->setScale(0.8); leftSprite->setPosition(ccp(leftSprite->getContentSize().width*0.6, leftSprite->getContentSize().height/2 *0.8)); leftSprite->setTag(1); leftSprite->setOpacity(0); spriteBatch->addChild(leftSprite, 0); CCSprite *rightSprite=CCSprite::createWithSpriteFrameName("blank.png"); //rightSprite->setScale(0.8); rightSprite->setPosition(ccp(800, 130)); rightSprite->setTag(2); rightSprite->setOpacity(0); spriteBatch->addChild(rightSprite, 0); avgGame(); return true; }
void PopupLayer::onEnter(){ CCLayer::onEnter(); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint pCenter = ccp(winSize.width / 2, winSize.height / 2); CCSize contentSize; // 设定好参数,在运行时加载 if (getContentSize().equals(CCSizeZero)) { getSpriteBackGround()->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(getSpriteBackGround(), 0, 0); contentSize = getSpriteBackGround()->getTexture()->getContentSize(); } else { Scale9Sprite *background = getSprite9BackGround(); background->setContentSize(getContentSize()); background->setPosition(ccp(winSize.width / 2, winSize.height / 2)); this->addChild(background, 0, 0); contentSize = getContentSize(); } // 添加按钮,并设置其位置 this->addChild(getMenuButton()); float btnWidth = contentSize.width / (getMenuButton()->getChildrenCount() + 1); // Array* array = getMenuButton()->getChildren(); Vector<Node*>& array = getMenuButton()->getChildren(); Object* pObj = NULL; int i = 0; /* vector<NODE>::iterator it; for (it=v.begin(); it!=v.end(); it++) { v[*it]->id=2; } */ Vector<Node*>::iterator it; for (it=array.begin() ; it!=array.end(); it++) { Node* node = dynamic_cast<Node*>(pObj); node->setPosition(ccp( winSize.width / 2 - contentSize.width / 2 + btnWidth * (i + 1), winSize.height / 2 - contentSize.height / 3)); i++; } // 显示对话框标题 if (getLabelTitle()){ getLabelTitle()->setPosition(ccpAdd(pCenter, ccp(0, contentSize.height / 2 - 35.0f))); this->addChild(getLabelTitle()); } // 显示文本内容 if (getLabelContentText()){ CCLabelTTF* ltf = getLabelContentText(); ltf->setPosition(ccp(winSize.width / 2, winSize.height / 2)); ltf->setDimensions(CCSizeMake(contentSize.width - m_contentPadding * 2, contentSize.height - m_contentPaddingTop)); ltf->setHorizontalAlignment(kCCTextAlignmentLeft); this->addChild(ltf); } // 弹出效果 CCAction* popupLayer = CCSequence::create(CCScaleTo::create(0.0, 0.0), CCScaleTo::create(0.06, 1.05), CCScaleTo::create(0.08, 0.95), CCScaleTo::create(0.08, 1.0), NULL); this->runAction(popupLayer); }
void BroadGameRankButton::init( Layer* parentLayer, PokerPlayerRankInfo* ptrFriendInfo, int index, bool isShowFriend ) { initWithNormalSprite(m_ptrNormal, m_ptrSelected, NULL, parentLayer, NULL); PokerPlayerRankInfo friendInfo; if(ptrFriendInfo->account_id == GameUtils::s_myInfo.getAccountID()) { friendInfo = *ptrFriendInfo; friendInfo.onlineType = OFF_LINE; ptrFriendInfo = &friendInfo; } if (ptrFriendInfo->account_id == GameUtils::s_myInfo.getAccountID()) { CCScale9Sprite* ptrCellBgCover = GameUtils::createScale9("light_blue_bg.png", CCRectMake(0,0,88,88),CCRectMake(30,30,25,25)); ptrCellBgCover->setContentSize(CCSizeMake(434,128)); ptrCellBgCover->setOpacity(0.5 * 255); addChild(ptrCellBgCover); LayoutUtil::layoutParentCenter(ptrCellBgCover); } // Rank if(index <= 2 && index >= 0 && ptrFriendInfo->winCount > 0) { char buf[40] ; sprintf(buf,"rank_%d.png",index + 1); CCSprite* ptrCupSprite = CREATE_SPRITE(this,buf,true); addChild(ptrCupSprite); LayoutUtil::layoutParentCenter(ptrCupSprite, -123); } else if(index <= -1 || ptrFriendInfo->winCount == 0) { CCLabelTTF* ptrLbRank = CCLabelTTF::create("---",FontConstant::TTF_IMPACT,30); addChild(ptrLbRank); LayoutUtil::layoutParentCenter(ptrLbRank, -123); } else { char buf[10]; sprintf(buf, "%d", index + 1); CCLabelTTF* ptrLbRank = CCLabelTTF::create(buf,FontConstant::TTF_IMPACT,30); addChild(ptrLbRank); LayoutUtil::layoutParentCenter(ptrLbRank, -123); } // Head Portrait string photoPath; GameUtils::getPhotoPath(photoPath,ptrFriendInfo->account_id,ptrFriendInfo->photo); CCSprite* ptrHeadSprite = CREATE_SPRITE(this,photoPath.c_str(),true); Icon* ptrIcon = Icon::create(86.0f); addChild(ptrIcon); ptrIcon->setContent(ptrHeadSprite); ptrIcon->setStencil(CREATE_SPRITE(this,"photo_mask_clip.png",true)); LayoutUtil::layoutParentLeft(ptrIcon, 72); ptrIcon->setCover(CREATE_SPRITE(this,"photo_mask.png",true)); // Name string name = ptrFriendInfo->account_id == GameUtils::s_myInfo.getAccountID() ? GameUtils::s_myInfo.getNickName() : ptrFriendInfo->nickName; name = GameUtils::cutName(name,12); CCLabelTTF* ptrLbName = CCLabelTTF::create(name.c_str(), FontConstant::TTF_IMPACT, 22); ptrLbName->setDimensions(CCSizeMake(145,ptrLbName->getContentSize().height)); ptrLbName->setHorizontalAlignment(kCCTextAlignmentLeft); addChild(ptrLbName); LayoutUtil::layoutParentLeftTop(ptrLbName, 172, -10); if(!isShowFriend) { // Win CCLabelTTF* ptrLbWin = CCLabelTTF::create(LOCALIZED_STRING("win_label"), FontConstant::TTF_IMPACT,24); ptrLbWin->setColor(ccc3(255,234,0)); addChild(ptrLbWin); LayoutUtil::layoutParentLeftTop(ptrLbWin, 172, -43); // Win Count CCLabelTTF* ptrLbWinCount = CCLabelTTF::create( Utils::num2strF(ptrFriendInfo->winCount,8,",",false).c_str(), FontConstant::TTF_IMPACT, 22); ptrLbWinCount->setColor(ccc3(0,255,255)); addChild(ptrLbWinCount); LayoutUtil::layoutRight(ptrLbWinCount, ptrLbWin); } else { if(ptrFriendInfo->onlineType == ON_LINE_NORMAL) { // Icon CCSprite* ptrGreenIcon = CREATE_SPRITE(this, "ico_green.png", true); addChild(ptrGreenIcon); LayoutUtil::layoutParentLeftTop(ptrGreenIcon, 166, -43); } else { CCLabelTTF* ptrLbWin = CCLabelTTF::create(LOCALIZED_STRING("win_label"), FontConstant::TTF_IMPACT,24); ptrLbWin->setColor(ccc3(255,234,0)); addChild(ptrLbWin); LayoutUtil::layoutParentLeftTop(ptrLbWin, 172, -43); CCLabelTTF* ptrLbWinCount = CCLabelTTF::create( Utils::num2strF(ptrFriendInfo->winCount,8,",",false).c_str(), FontConstant::TTF_IMPACT,22); ptrLbWinCount->setColor(ccc3(0,255,255)); addChild(ptrLbWinCount); LayoutUtil::layoutRight(ptrLbWinCount, ptrLbWin); if (ptrFriendInfo->onlineType > ON_LINE_NORMAL) { CCSprite* ptrStatusBg = CREATE_SPRITE(this,"status_bg.png",false); addChild(ptrStatusBg); LayoutUtil::layoutBottom(ptrStatusBg,ptrIcon,0,24); string path = "in_sng.png"; if (ptrFriendInfo->onlineType == ON_LINE_SO) { path = "in_shootout.png"; } CCSprite* ptrOnlineStatus = CREATE_SPRITE(this,path.c_str(),false); ptrStatusBg->addChild(ptrOnlineStatus); LayoutUtil::layoutParentCenter(ptrOnlineStatus); } } } //line CCSprite* ptrBottomLine = CREATE_SPRITE(this,"Images/separator_line_thin.png",true); ptrBottomLine->setScaleX(0.328f); addChild(ptrBottomLine); LayoutUtil::layoutParentBottom(ptrBottomLine,0,-17); }
DNKMyChatTableViewCell *DNKMyChatTableViewCell::initCell(string answer, int talkTime){ float cellHeight = DNKCommon::calculateHeightOfTalkMyCell(answer, kTALK_DETAIL_POST_TEXT_SIZE, kTALK_DETAIL_POST_TEXT_WIDTH); float textHeight = DNKCommon::calculateHeightOfLabel(answer, kTALK_DETAIL_POST_TEXT_SIZE, kTALK_DETAIL_POST_TEXT_WIDTH); // Size visibleSize = Director::getInstance()->getVisibleSize(); // auto bg = Sprite::create(); // bg->setAnchorPoint(Vec2(0, 0)); // bg->setTextureRect(Rect(0, 0, visibleSize.width, cellHeight)); // bg->setColor(Color3B(230,230,230)); // this->addChild(bg); // auto line = Sprite::create(); // line->setAnchorPoint(Vec2(0, 0)); // line->setTextureRect(Rect(0, 0, visibleSize.width, 1)); // line->setColor(Color3B(100,100,100)); // this->addChild(line); cocos2d::ui::ImageView* bubbleRight = cocos2d::ui::ImageView::create("res/talk/fukisashi_u_r.png"); bubbleRight->setAnchorPoint(Vec2(0, 0)); bubbleRight->setPosition(Vec2(200, cellHeight - 10)); this->addChild(bubbleRight); cocos2d::ui::ImageView* downbubble = cocos2d::ui::ImageView::create("res/talk/fukisashi_d_r.png"); downbubble->setAnchorPoint(Vec2(0, 0)); downbubble->setPosition(Vec2(200, cellHeight - textHeight - 10)); this->addChild(downbubble); cocos2d::ui::ImageView* middlebubble = cocos2d::ui::ImageView::create("res/talk/fukisashi_m_r.png"); middlebubble->setAnchorPoint(Vec2(0, 0)); float middlebubbleHeight = bubbleRight->getPositionY() - downbubble->getPositionY() - downbubble->getContentSize().height; // middlebubble->setContentSize(Size(100, 400)); middlebubble->setScale(1, middlebubbleHeight/middlebubble->getContentSize().height); middlebubble->setPosition(Vec2(200, downbubble->getPositionY() + downbubble->getContentSize().height)); this->addChild(middlebubble); // CCLabelTTF* friendName = CCLabelTTF::create(friendInfo->getName(), "MSGothic", 20); // friendName->setColor(Color3B::BLACK); // friendName->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); // friendName->setPosition(Vec2(130, cellHeight - 30)); // friendName->setAnchorPoint(Vec2(0, 0)); // friendName->setDimensions(Size(Vec2(kTALK_DETAIL_POST_TEXT_WIDTH, 0))); // this->addChild(friendName); // auto image = Sprite::create("detail.png"); // image->setScale(0.25); // image->setAnchorPoint(Vec2(0.5, 0.5)); // image->setPosition(Vec2(50, visibleSize.height*0.1)); // this->addChild(image); // auto text = StringUtils::format("Cell 10"); // auto label = Label::createWithSystemFont(text.c_str(), "Arial", 30); // label->setAnchorPoint(Vec2(0, 0.5)); // label->setPosition(Vec2(visibleSize.width - 100, visibleSize.height*.1)); // label->setColor(Color3B(100,100,100)); // this->addChild(label); CCLabelTTF* lbl = CCLabelTTF::create(answer, kDEFAULT_BOLD_FONT, kTALK_DETAIL_POST_TEXT_SIZE); lbl->setColor(Color3B::BLACK); lbl->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); lbl->setPosition(Vec2(220, cellHeight - textHeight + 20)); lbl->setAnchorPoint(Vec2(0, 0)); lbl->setDimensions(Size(Vec2(kTALK_DETAIL_POST_TEXT_WIDTH, 0))); this->addChild(lbl); CCLabelTTF* timeLbl = CCLabelTTF::create(DNKCommon::convertTime(talkTime), kDEFAULT_FONT, 20); timeLbl->setColor(Color3B::BLACK); timeLbl->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); timeLbl->setAnchorPoint(Vec2(0, 0)); timeLbl->setPosition(Vec2(150, cellHeight - textHeight + 10)); this->addChild(timeLbl); CCLabelTTF* readed = CCLabelTTF::create("既読", kDEFAULT_FONT, 20); readed->setColor(Color3B::BLACK); readed->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT); readed->setAnchorPoint(Vec2(0, 0)); readed->setPosition(Vec2(150, cellHeight - textHeight + 40)); this->addChild(readed); return this; }
void MailListTile::setSystemMail(Email mail) { m_sSystemMail = mail; string biaotiImg[5] = {"denglujiangli_langtiao.png","denglujiangli_langtiao.png","denglujiangli_hongtiao.png","denglujiangli_hangtiao.png","denglujiangli_zitiao.png"}; string titleStr[5] = {LFStrings::getValue("XiTongJiangli"),LFStrings::getValue("XiTongBuChang"),LFStrings::getValue("XiTongTongZhi"),LFStrings::getValue("HaoYouShenQing"),LFStrings::getValue("HaoYouShanChu")}; CCSprite *bgSpr = CCSprite::create("denglujiangli_jinri_bg.png"); bgSpr->setAnchorPoint(CCPointZero); CCPoint pos; pos.x = 5; pos.y = 0; bgSpr->setPosition(pos); addChild(bgSpr,-1); m_sBgSpr = bgSpr; int side = 10; this->setContentSize(bgSpr->getContentSize()); {//标题 CCSprite *titleSpr = CCSprite::create(biaotiImg[mail.type].c_str()); titleSpr->setPosition(ccp(bgSpr->getContentSize().width / 2,bgSpr->getContentSize().height - titleSpr->getContentSize().height / 2)); bgSpr->addChild(titleSpr); CCLabelTTF *titleTTF = CCLabelTTF::create(titleStr[mail.type].c_str(),fontStr_kaiti,20.0f); titleTTF->setPosition(titleSpr->getPosition()); bgSpr->addChild(titleTTF); titleTTF->setColor(ccWHITE); string info; if (mail.summary.length() > 1) { info = mail.summary; } else { info = mail.content; } //内容 switch (mail.type) { case 0: case 1: { CCLabelTTF *ttf = CCLabelTTF::create(info.c_str(),fontStr_kaiti,20.0f); ttf->setAnchorPoint(ccp(0,1.0f)); ttf->setPosition(ccp(ttf->getContentSize().height ,bgSpr->getContentSize().height - titleSpr->getContentSize().height - side)); ttf->setDimensions(CCSizeMake(bgSpr->getContentSize().width - 2 * ttf->getContentSize().height,bgSpr->getContentSize().height - titleSpr->getContentSize().height)); ttf->setHorizontalAlignment(kCCTextAlignmentLeft); bgSpr->addChild(ttf); ttf->setColor(m_cTTFColor); if (mail.is_read) { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_shanchu.png","youxiang_anniu_shanchu_select.png","youxiang_anniu_shanchu_select.png",this,SEL_MenuHandler(&MailListTile::selectDelete)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); CCSprite *koSpr = CCSprite::create("jingjichang_wanjiazhuangtailan_ko.png"); koSpr->setPosition(ccp(bgSpr->getContentSize().width - koSpr->getContentSize().width / 2 - menuItem->getContentSize().width, 20 + koSpr->getContentSize().height / 2)); bgSpr->addChild(koSpr); } else { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_xiangqing.png","youxiang_anniu_xiangqing_select.png","youxiang_anniu_xiangqing_select.png",this,SEL_MenuHandler(&MailListTile::selectCheckInfo)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); } } break; case 2: { CCLabelTTF *ttf = CCLabelTTF::create(info.c_str(),fontStr_kaiti,20.0f); ttf->setAnchorPoint(ccp(0,1.0f)); ttf->setPosition(ccp(ttf->getContentSize().height ,bgSpr->getContentSize().height - titleSpr->getContentSize().height - side)); ttf->setDimensions(CCSizeMake(bgSpr->getContentSize().width - 2 * ttf->getContentSize().height,bgSpr->getContentSize().height - titleSpr->getContentSize().height)); ttf->setHorizontalAlignment(kCCTextAlignmentLeft); bgSpr->addChild(ttf); ttf->setColor(m_cTTFColor); if (mail.is_read) { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_xiangqing.png","youxiang_anniu_xiangqing_select.png","youxiang_anniu_xiangqing_select.png",this,SEL_MenuHandler(&MailListTile::selectCheckInfo)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide * 2 - menuItem->getContentSize().width,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); CCMenuItemImage *menuItem2 = CCMenuItemImage::create("youxiang_anniu_shanchu.png","youxiang_anniu_shanchu_select.png","youxiang_anniu_shanchu_select.png",this,SEL_MenuHandler(&MailListTile::selectDelete)); menuItem2->setTag(mail.email_id); menuItem2->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem2->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem2->getContentSize().height / 2)); m_mMenu->addChild(menuItem2); } else { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_xiangqing.png","youxiang_anniu_xiangqing_select.png","youxiang_anniu_xiangqing_select.png",this,SEL_MenuHandler(&MailListTile::selectCheckInfo)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); } } break; case 3: { CCLabelTTF *ttf = CCLabelTTF::create(CCString::createWithFormat("%s",mail.addresserName.c_str())->getCString(),fontStr_kaiti,20.0f); ttf->setAnchorPoint(ccp(0,1.0f)); ttf->setPosition(ccp(ttf->getContentSize().height ,bgSpr->getContentSize().height - titleSpr->getContentSize().height - side)); //ttf->setDimensions(CCSizeMake(bgSpr->getContentSize().width - 2 * ttf->getContentSize().height,bgSpr->getContentSize().height - titleSpr->getContentSize().height)); ttf->setHorizontalAlignment(kCCTextAlignmentLeft); bgSpr->addChild(ttf); CCLabelTTF *ttf2 = CCLabelTTF::create(CCString::createWithFormat("%s",info.c_str())->getCString(),fontStr_kaiti,20.0f); ttf2->setAnchorPoint(ccp(0,1.0f)); ttf2->setPosition(ccp(ttf->getPositionX() + ttf->getContentSize().width ,ttf->getPositionY())); ttf2->setDimensions(CCSizeMake(bgSpr->getContentSize().width - ttf->getPositionX() - ttf->getContentSize().width ,ttf->getPositionY())); ttf2->setHorizontalAlignment(kCCTextAlignmentLeft); bgSpr->addChild(ttf2); ttf2->setColor(m_cTTFColor); if (ttf->getContentSize().height == 0) { ttf2->setPosition(ccp(30.0f ,ttf->getPositionY())); } if (mail.is_read) { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_shanchu.png","youxiang_anniu_shanchu_select.png","youxiang_anniu_shanchu_select.png",this,SEL_MenuHandler(&MailListTile::selectDelete)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); } else { CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_jieshou.png","youxiang_anniu_jieshou_select.png","youxiang_anniu_jieshou_select.png",this,SEL_MenuHandler(&MailListTile::selectOK)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide * 2 - menuItem->getContentSize().width,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); CCMenuItemImage *menuItem2 = CCMenuItemImage::create("youxiang_anniu_jujue.png","youxiang_anniu_jujue_select.png","youxiang_anniu_jujue_select.png",this,SEL_MenuHandler(&MailListTile::selectCancel)); menuItem2->setTag(mail.email_id); menuItem2->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem2->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem2->getContentSize().height / 2)); m_mMenu->addChild(menuItem2); } } break; case 4: { CCLabelTTF *ttf = CCLabelTTF::create(CCString::createWithFormat("%s",info.c_str())->getCString(),fontStr_kaiti,20.0f); ttf->setAnchorPoint(ccp(0,1.0f)); ttf->setPosition(ccp(ttf->getContentSize().height ,bgSpr->getContentSize().height - titleSpr->getContentSize().height - side)); ttf->setDimensions(CCSizeMake(bgSpr->getContentSize().width - 2 * ttf->getContentSize().height,bgSpr->getContentSize().height - titleSpr->getContentSize().height)); ttf->setHorizontalAlignment(kCCTextAlignmentLeft); bgSpr->addChild(ttf); ttf->setColor(ccRED); CCMenuItemImage *menuItem = CCMenuItemImage::create("youxiang_anniu_shanchu.png","youxiang_anniu_shanchu_select.png","youxiang_anniu_shanchu_select.png",this,SEL_MenuHandler(&MailListTile::selectDelete)); menuItem->setTag(mail.email_id); menuItem->setPosition(ccp(bgSpr->getPositionX() + bgSpr->getContentSize().width - menuItem->getContentSize().width / 2 - m_nSide,pos.y + m_nSide + menuItem->getContentSize().height / 2)); m_mMenu->addChild(menuItem); } break; default: break; } } }
void StoryWorld::makeAChoice(CCObject *sender) { int choice = ((CCNode *)sender)->getTag(); if (current == '3') { switch (choice) { case fChoice: { // 显示宣传单一 cout << "xuanchuan " << endl; removeChildByTag(2); removeChildByTag(3); CCSprite *blackBG = CCSprite::create(BLACK_IMG_PATH); blackBG->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2)); blackBG->setScale(1); blackBG->setTag(21); addChild(blackBG, 2); // TODO CCLabelTTF *xuanchuan = CCLabelTTF::create(); xuanchuan->setPosition(ccp(0, 40)); xuanchuan->setHorizontalAlignment(kCCTextAlignmentLeft); xuanchuan->setAnchorPoint(CCPointZero); xuanchuan->setDimensions(CCSizeMake(1100, 0)); xuanchuan->setTag(22); addChild(xuanchuan, 3); // 关闭按钮 CCMenuItemImage *start = CCMenuItemImage::create(LEAFLET_IMG_PATH, LEAFLET_IMG_PATH, this, menu_selector(StoryWorld::menuLeafletsCloseCallback)); start->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width-40, CCDirector::sharedDirector()->getVisibleSize().height-40)); //菜单 CCMenu* pMenu = CCMenu::create(start, NULL); pMenu->setPosition(CCPointZero); pMenu->setTag(23); addChild(pMenu, 4); } return; case sChoice: default:{ current+=1; CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit); CCDirector::sharedDirector()->popScene(); } return; } } char fileName[8] = "Fin "; switch (choice) { case fChoice: fileName[3]='1'; break; case sChoice: fileName[3]='2'; break; case tChoice: fileName[3]='3'; break; default: break; } reader.ChangeFile(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName)); removeChildByTag(2); removeChildByTag(3); setTouchEnabled(true); avgGame(); }