bool VVAlertViewForLogin::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle, const char* aPlaceHolderUser, const char* aPlaceHolderPassword, VVTextFieldDelegate* aTextDelegate) { if( !VVAlertView::initWithTitle(aTitle, aMessage, aDelegate, aCancelBtnTitle,aOtherBtnTitle,centerPadding) ) return false; float txtBoxPaddingLeft = 10; float txtBoxPaddingTop = 5; CCScale9Sprite *txtbg = CCScale9Sprite::scale9SpriteWithFile(paramUser.fieldBG_name.c_str(), paramUser.field9patch_rect); if( txtbg ) { txtbg->setContentSize(CCSizeMake(paramUser.fieldSize.width+txtBoxPaddingLeft*2, paramUser.fieldSize.height+txtBoxPaddingTop*2)); txtbg->setAnchorPoint(ccp(0.5,0)); txtbg->setPosition(ccp(0, centerOfMargin+paramUser.fieldSize.height*4/5-txtBoxPaddingTop)); addChild(txtbg); } txtbg = NULL; txtbg = CCScale9Sprite::scale9SpriteWithFile(paramPassword.fieldBG_name.c_str(), paramPassword.field9patch_rect); if( txtbg ) { txtbg->setContentSize(CCSizeMake(paramUser.fieldSize.width+txtBoxPaddingLeft*2, paramUser.fieldSize.height+txtBoxPaddingTop*2)); txtbg->setAnchorPoint(ccp(0.5,0)); txtbg->setPosition(ccp(0, centerOfMargin-paramPassword.fieldSize.height*4/5-txtBoxPaddingTop)); addChild(txtbg); } txtUser = new VVTextField(); txtUser->initWithPlaceHolder(aPlaceHolderUser, fontName.c_str(), paramUser.textFieldFontSize, paramUser.maxFieldLength, paramUser.fieldSize); txtUser->setPosition(ccp(-paramUser.fieldSize.width/2, centerOfMargin+paramUser.fieldSize.height*4/5)); txtUser->setDelegate(aTextDelegate); txtUser->setTag(VVAlertViewForLoginTypeUser); txtUser->setIsAcceptingOnlyASCII(true); addChild(txtUser); txtUser->release(); txtPassword = new VVTextField(); txtPassword->initWithPlaceHolder(aPlaceHolderPassword, fontName.c_str(), paramPassword.textFieldFontSize, paramPassword.maxFieldLength, paramPassword.fieldSize); txtPassword->setPosition(ccp(-paramPassword.fieldSize.width/2, centerOfMargin-paramPassword.fieldSize.height*4/5)); txtPassword->setDelegate(aTextDelegate); txtPassword->setTag(VVAlertViewForLoginTypePassword); txtPassword->setIsPasswordText(true); txtPassword->setIsAcceptingOnlyASCII(true); addChild(txtPassword); txtPassword->release(); return true; }
bool MoreDiamondDialog::init() { if ( !CCLayerColor::initWithColor(DIM_COLOR) ) { return false; } CCPoint pask = ccp(400, 1280 - 1000); CCScale9Sprite* dialog = CCScale9Sprite::create("dialog.png"); dialog->setPosition(ccp(400, 1280-750)); dialog->setContentSize(CCSizeMake(768, 640)); this->addChild(dialog); CCScale9Sprite* dialogTop = CCScale9Sprite::create("dialog.png"); dialogTop->setPosition(ccp(400, 1280-481)); dialogTop->setContentSize(CCSizeMake(768, 100)); this->addChild(dialogTop); MY_ADD_LABELTTF(labelTitle, "Thêm kim cương", CONF_STR(FONT_NORMAL), 48, ccBLACK, ccp(400, 1280 - 484)); MY_ADD_MENU_ITEM_LABEL(itlbRate, CCString::createWithFormat("+ %d: Rate 5 sao", CONF_INT(DIAMOND_FOR_RATE))->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::rateCallback, ANCHOR_LEFT, ccp(188, 1280-628)); MY_ADD_MENU_ITEM_LABEL(itlbInvite, CCString::createWithFormat("+ %d: Mời 1 bạn", CONF_INT(DIAMOND_FOR_INVITE))->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::inviteCallback, ANCHOR_LEFT, ccp(188, 1280-738)); MY_ADD_MENU_ITEM_LABEL(itlbShare, CCString::createWithFormat("+ %d: Chia sẻ", CONF_INT(DIAMOND_FOR_SHARE))->getCString(), CONF_STR(FONT_NORMAL), 48, ccBLACK, MoreDiamondDialog::shareCallback, ANCHOR_LEFT, ccp(188, 1280-848)); m_itlbRate = itlbRate; m_itlbInvite = itlbInvite; m_itlbShare = itlbShare; MY_ADD_SPRITE(sprRate, "rateIcon.png", ccp(108, 1280-628)); MY_ADD_SPRITE(sprInvite, "inviteIcon.png", ccp(108, 1280-738)); MY_ADD_SPRITE(sprShare, "shareIcon.png", ccp(108, 1280-848)); //check if (DataManager::sharedDataManager()->GetIsRatedApp() == true) { m_itlbRate->setEnabled(false); m_itlbRate->setOpacity(100); } MY_ADD_MENU_ITEM(itExit, "exit_button.png", "exit_button_press.png", "exit_button_press.png", MoreDiamondDialog::exitCallback, pask); this->setKeypadEnabled(true); return true; }
bool ToTextLayer::DerSelMenu(Script* ts){ do{ CC_BREAK_IF(!ts); //CCDictionary* attrs = ts->attributes; CCArray* scrs = ts->scriptnodes; int n = ts->m_snum; int maxleng = 0; /* <最大字长 */ CCArray* tm = CCArray::createWithCapacity(n); for(int i=0;i<n;i++){ Script* tmp = (Script*) scrs->objectAtIndex(i); //set more here if you want more. float sf = 1; CCSprite* spriteNormal; CCSprite* spriteSelected; CCSprite* spriteDisabled; spriteNormal = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*2/sf,70/sf,23/sf)); spriteSelected = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*1/sf,70/sf,23/sf)); spriteDisabled = CCSprite::create("Images/menuitemsprite2.png", CCRectMake(0,23*0,70/sf,23/sf)); SpriteTextMenuItem* item2 = new SpriteTextMenuItem(); item2->autorelease(); item2->initWithNormalSprite(spriteNormal, spriteSelected, spriteDisabled,this, menu_selector(ToTextLayer::menucallback) ); item2->settext(tmp->getstring("content"), FNT_CHN, 24); item2->setSData(tmp->getint("jump")); item2->setTag(100+i); maxleng = max(maxleng, strlen(tmp->getstring("content"))); tm->insertObject(item2,i); } sel_menu = MouseMenu::createWithArray(tm); sel_menu->setTouchEnabled(false); sel_menu->alignItemsVertically(); sel_menu->setTag(MENUTAG); sel_menu->setPosition(ccp(s.width/2, s.height/2)); sel_menu->f_setaligntype(1); addChild(sel_menu); float t_width,t_height; t_width = maxleng * 30; t_height = n * 30; CCScale9Sprite* nback = CCScale9Sprite::create("Images/popup_back.png"); nback->setContentSize(CCSize(t_width+ 23,t_height+ 22)); nback->setAnchorPoint(ccp(0.5,0.5)); nback->setPosition(s.width/2, s.height/2 - t_height/2 +30 ); nback->setOpacity(200); nback->setTag(MENUTAG+1); addChild(nback,-1); e_layerstate = 1; return true; }while(0); return false; }
LFToast::LFToast(string msg,float during) { CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCScale9Sprite* base = CCScale9Sprite::create("toast.png"); CCLabelTTF* lable = CCLabelTTF::create( msg.c_str(), fontStr_kaiti, 30, CCSize(base->getContentSize().width - 10,0), kCCTextAlignmentLeft); lable->setAnchorPoint(ccp(0,0.5f)); addChild(base); base->setContentSize(CCSizeMake(base->getContentSize().width,lable->getContentSize().height + 20)); base->setOpacity(0); base->addChild(lable); lable->setPosition(ccp(10,base->getContentSize().height/2)); base->setPosition(ccp(visibleSize.width/2,base->getContentSize().height + 20)); base->runAction(CCSequence::create( CCFadeTo::create(0.2f,255), CCDelayTime::create(during), CCFadeTo::create(0.1f,0), CCCallFuncN::create(this,SEL_CallFuncN(&LFToast::removeToast)), NULL )); }
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 { CCScale9Sprite *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); CCArray* array = getMenuButton()->getChildren(); CCObject* pObj = NULL; int i = 0; CCARRAY_FOREACH(array, pObj){ CCNode* node = dynamic_cast<CCNode*>(pObj); node->setPosition(ccp( winSize.width / 2 - contentSize.width / 2 + btnWidth * (i + 1), winSize.height / 2 - contentSize.height / 3)); i++; }
void GameRankLayer::initTabs() { // Friend Tab CCScale9Sprite* ptrTabFriendsSelected = GameUtils::createScale9("new_blue_bg.png", CCRectMake(0,0,200,82),CCRectMake(35,35,125,10)); ptrTabFriendsSelected->setContentSize(CCSizeMake(204,82)); CCScale9Sprite* ptrTabFriendsDisabled = GameUtils::createScale9("new_blue_bg.png", CCRectMake(0,0,200,82),CCRectMake(35,35,125,10)); ptrTabFriendsDisabled->setContentSize(CCSizeMake(204,82)); CCNode* ptrTabFriendsNormal = CCNode::create(); ptrTabFriendsNormal->setContentSize(ptrTabFriendsSelected->getContentSize()); m_ptrTabFriends = CCMenuItemSprite::create(ptrTabFriendsNormal, ptrTabFriendsSelected, ptrTabFriendsDisabled, this, menu_selector(GameRankLayer::tabFriendsCallback)); m_ptrBg->addChild(m_ptrTabFriends); LayoutUtil::layoutParentLeftTop(m_ptrTabFriends, -5, -27); registerMenuItem(m_ptrTabFriends); m_ptrLbFriends = CCLabelBMFont::create(LOCALIZED_STRING("word_friends"), FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE); m_ptrLbFriends->setScale(0.6f); m_ptrTabFriends->addChild(m_ptrLbFriends); LayoutUtil::layoutParentBottom(m_ptrLbFriends,6,22); // Global Tab CCScale9Sprite* ptrTabGlobalSelected = GameUtils::createScale9("new_blue_bg.png", CCRectMake(0,0,200,82),CCRectMake(35,35,125,10)); ptrTabGlobalSelected->setContentSize(CCSizeMake(204,82)); CCScale9Sprite* ptrTabGlobalDisabled = GameUtils::createScale9("new_blue_bg.png", CCRectMake(0,0,200,82),CCRectMake(35,35,125,10)); ptrTabGlobalDisabled->setContentSize(CCSizeMake(204,82)); CCNode* ptrTabGlobalNormal = CCNode::create(); ptrTabGlobalNormal->setContentSize(ptrTabGlobalSelected->getContentSize()); m_ptrTabGolbal = CCMenuItemSprite::create(ptrTabGlobalNormal, ptrTabGlobalSelected, ptrTabGlobalDisabled,this, menu_selector(GameRankLayer::tabGlobalCallback)); m_ptrBg->addChild(m_ptrTabGolbal); LayoutUtil::layoutRight(m_ptrTabGolbal,m_ptrTabFriends,-44); registerMenuItem(m_ptrTabGolbal); m_ptrLbGlobal = CCLabelBMFont::create(LOCALIZED_STRING("word_global"), FontConstant::BMFONT_GOTHIC725_BLK_BT_BLUE); m_ptrLbGlobal->setScale(0.6f); m_ptrTabGolbal->addChild(m_ptrLbGlobal); LayoutUtil::layoutParentBottom(m_ptrLbGlobal,5,22); tabFriendsCallback(NULL); }
void SoloGameScene::initQuestionItems() { int boxW = 774; CCScale9Sprite* quesContent = CCScale9Sprite::create("dialog.png"); quesContent->setPosition(ccp(400, 1280-588)); quesContent->setContentSize(CCSizeMake(boxW, 412)); this->addChild(quesContent); CCScale9Sprite* quesNumber = CCScale9Sprite::create("dialog.png"); quesNumber->setPosition(ccp(400, 1280-345)); quesNumber->setContentSize(CCSizeMake(390, 128)); this->addChild(quesNumber); MY_ADD_LABELTTF( _lbNumber, "", CONF_STR(FONT_NORMAL), 64, ccBLACK, ccp(400, 1280-340)); m_lbNumber = _lbNumber; m_lbQuestion = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 48, CCSizeMake(9.0f * boxW / 10.0f, 0), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter); m_lbQuestion->setFontFillColor(ccBLACK); m_lbQuestion->setColor(ccBLACK); m_lbQuestion->setPosition(ccp(400, 1280-600)); this->addChild(m_lbQuestion); for (int i = 0; i < 4; ++i) { m_itAnswers[i] = CCMenuItemImage::create("answer.png", "answer_down.png", "answer_disable.png", this, menu_selector(SoloGameScene::answerCallback)); m_itAnswers[i]->setPosition(ccp(400, 1280-843 - i*94)); m_itAnswers[i]->setTag(i); m_menu->addChild(m_itAnswers[i]); } for (int i = 0; i < 4; ++i) { m_lbAnswers[i] = CCLabelTTF::create("", CONF_STR(FONT_NORMAL), 48); m_lbAnswers[i]->setFontFillColor(ccBLACK); m_lbAnswers[i]->setColor(ccBLACK); m_lbAnswers[i]->setAnchorPoint(ANCHOR_LEFT); m_lbAnswers[i]->setPosition(ccp(140, 1280-840 - i*94)); this->addChild(m_lbAnswers[i]); } }
void AchievementNotification::showImmediately(Achievement a) { mShowing = true; CCTexture2D* tex = CCTextureCache::sharedTextureCache()->textureForKey(fileName.c_str()); if (tex == NULL) { tex = CCTextureCache::sharedTextureCache()->addImage(fileName.c_str()); } CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCScale9Sprite* pBoard = CCScale9Sprite::create(CCRectMake(tex->getContentSize().width/2, 0, 2, tex->getContentSize().height), fileName.c_str()); addChild(pBoard,0,Tag_Board); pBoard->setPosition(ccp(winSize.width/2,winSize.height + pBoard->getContentSize().height) ); CCSprite* pJinBei = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_jiangbei.png").c_str()); pBoard->addChild(pJinBei, 1); pJinBei->setPosition(ccp(pJinBei->getContentSize().width, pBoard->getContentSize().height/2)); CCLabelTTF* pName = CCLabelTTF::create(a.name.c_str(), fontStr_KlavikaBold, 40); pName->setColor(fontColor_Acheivement_TTF); CCSprite* pIcon = CCSprite::create(ResManager::getManager()->getFilePath(g_public+"CJ_icon_wancheng.png").c_str()); int x = pName->getContentSize().width + pIcon->getContentSize().width - 420; if (x > 0) { pBoard->setContentSize(ccp(pBoard->getContentSize().width+x, pBoard->getContentSize().height)); } pBoard->addChild(pName); int xoffset = 10; pName->setPosition(ccp(pBoard->getContentSize().width/2 + pIcon->getContentSize().width/2 + xoffset, pBoard->getContentSize().height/2)); pBoard->addChild(pIcon); pIcon->setPosition(ccp(pName->getPositionX() - pName->getContentSize().width/2 - pIcon->getContentSize().width/2 - xoffset, pName->getPositionY())); Achievement* achievementCopy = new Achievement(a); // *achievementCopy = a; temp_Must_Delete.insert(temp_Must_Delete.end(),achievementCopy); pBoard->runAction(CCSequence::create( CCMoveTo::create(0.5f,ccp(pBoard->getPositionX(),winSize.height-pBoard->getContentSize().height/2)), CCDelayTime::create(0.1f), CCCallFuncND::create(this,SEL_CallFuncND(&AchievementNotification::boardShowing),achievementCopy), CCDelayTime::create(1.3f), CCMoveTo::create(0.2f,ccp(pBoard->getPositionX(),winSize.height+pBoard->getContentSize().height)), CCFadeTo::create(0.1f,0), CCCallFuncN::create(this,SEL_CallFuncN(&AchievementNotification::boardShowEnd)),NULL)); createPar(ccp(winSize.width/2,winSize.height),parFileName.c_str(),pBoard->getContentSize().width * 1.2f,pBoard->getContentSize().height); Music::sharedMusicPlayer()->playEffectSound("achievement.wav"); CCLog("AchievementNotification::showImmediately name = %s" ,a.name.c_str()); }
bool CCControlPotentiometerTest::init() { if (CCControlScene::init()) { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); CCNode *layer = CCNode::create(); layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2)); this->addChild(layer, 1); double layer_width = 0; // Add the black background for the text CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(80, 50)); background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; this->setDisplayValueLabel(CCLabelTTF::create("", "HelveticaNeue-Bold", 30)); m_pDisplayValueLabel->setPosition(background->getPosition()); layer->addChild(m_pDisplayValueLabel); // Add the slider CCControlPotentiometer *potentiometer = CCControlPotentiometer::create("extensions/potentiometerTrack.png" ,"extensions/potentiometerProgress.png" ,"extensions/potentiometerButton.png"); potentiometer->setPosition(ccp (layer_width + 10 + potentiometer->getContentSize().width / 2, 0)); // When the value of the slider will change, the given selector will be call potentiometer->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlPotentiometerTest::valueChanged), CCControlEventValueChanged); layer->addChild(potentiometer); layer_width += potentiometer->getContentSize().width; // Set the layer size layer->setContentSize(CCSizeMake(layer_width, 0)); layer->setAnchorPoint(ccp (0.5f, 0.5f)); // Update the value label this->valueChanged(potentiometer, CCControlEventValueChanged); return true; } return false; }
bool IrrPanel::init( const char* texture,IrrSize size,bool isPlist /*= false*/ ) { CCScale9Sprite* pBackground = NULL; if(isPlist) { CCScale9Sprite* pBackground = CCScale9Sprite::createWithSpriteFrameName(texture); } else { CCScale9Sprite* pBackground = CCScale9Sprite::create(texture); } pBackground->setAnchorPoint(ccp(0,0)); pBackground->setContentSize(CCSize(size.width,size.height)); this->addChild(pBackground); return true; }
bool CCControlScene::init() { if (CCLayer::init()) { // Get the sceensize CCSize screensize = CCDirector::sharedDirector()->getWinSize(); CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this, menu_selector(CCControlScene::toExtensionsMainLayer)); pBackItem->setPosition(ccp(screensize.width - 50, 25)); CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL); pBackMenu->setPosition( CCPointZero ); addChild(pBackMenu, 10); // Add the generated background CCSprite *background = CCSprite::create("extensions/background.png"); background->setPosition(ccp(screensize.width / 2, screensize.height / 2)); addChild(background); // Add the ribbon CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55)); ribbon->setContentSize(CCSizeMake(screensize.width, 57)); ribbon->setPosition(ccp(screensize.width / 2.0f, screensize.height - ribbon->getContentSize().height / 2.0f)); addChild(ribbon); // Add the title setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12)); m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5)); addChild(m_pSceneTitleLabel, 1); // Add the menu CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback)); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback)); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback)); CCMenu *menu = CCMenu::create(item1, item3, item2, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(screensize.width / 2 - 100, 37)); item2->setPosition(ccp(screensize.width / 2, 35)); item3->setPosition(ccp(screensize.width / 2 + 100, 37)); addChild(menu ,1); return true; } return false; }
bool CCControlButtonTest_HelloVariableSize::init() { if (CCControlScene::init()) { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Defines an array of title to create buttons dynamically CCArray *stringArray = CCArray::create( ccs("Hello"), ccs("Variable"), ccs("Size"), ccs("!"), NULL); CCNode *layer = CCNode::create(); addChild(layer, 1); double total_width = 0, height = 0; // For each title in the array CCObject* pObj = NULL; CCARRAY_FOREACH(stringArray, pObj) { CCString* title = (CCString*)pObj; // Creates a button with this string as title CCControlButton *button = standardButtonWithTitle(title->getCString()); button->setPosition(ccp (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2)); layer->addChild(button); // Compute the size of the layer height = button->getContentSize().height; total_width += button->getContentSize().width; } layer->setAnchorPoint(ccp (0.5, 0.5)); layer->setContentSize(CCSizeMake(total_width, height)); layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(total_width + 14, height + 14)); background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); return true; }
void CCAnimate9SpriteProgress::update(float fraction) { CCNode* target = getTarget(); CCScale9Sprite* sprite = (CCScale9Sprite*)target; float width = beginSize.width + fraction * distance; if (capAtMax) width = std::min(width, maxWidth); else while (width - maxWidth > 1e-3) width -= maxWidth; if (width - minWidth < 1e-3) width = minWidth; sprite->setVisible(width > minWidth); sprite->setContentSize(CCSize(width, beginSize.height)); }
bool CCControlScene::init() { if (CCLayer::init()) { CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this, menu_selector(CCControlScene::toExtensionsMainLayer)); pBackItem->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25)); CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL); pBackMenu->setPosition( CCPointZero ); addChild(pBackMenu, 10); // Add the generated background CCSprite *background = CCSprite::create("extensions/background.png"); background->setPosition(VisibleRect::center()); addChild(background); // Add the ribbon CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55)); ribbon->setContentSize(CCSizeMake(VisibleRect::getVisibleRect().size.width, 57)); ribbon->setPosition(ccp(VisibleRect::center().x, VisibleRect::top().y - ribbon->getContentSize().height / 2.0f)); addChild(ribbon); // Add the title setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12)); m_pSceneTitleLabel->setPosition(ccp (VisibleRect::center().x, VisibleRect::top().y - m_pSceneTitleLabel->getContentSize().height / 2 - 5)); addChild(m_pSceneTitleLabel, 1); // Add the menu CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback)); CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback)); CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback)); CCMenu *menu = CCMenu::create(item1, item3, item2, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); item2->setPosition(ccp(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2)); item3->setPosition(ccp(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2)); addChild(menu ,1); return true; } return false; }
void ModelDialog::onEnter(){ CCLayer::onEnter(); CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); CCSize contentSize; if (getContentSize().equals(CCSizeZero)) { getSpriteBackGround()->setPosition(ccp(origin.x + visibleSize.width / 2 , origin.y + visibleSize.height / 2)); this->addChild(getSpriteBackGround(), 0, 0); contentSize = getSpriteBackGround()->getTexture()->getContentSize(); } else { contentSize = getContentSize(); CCScale9Sprite *background = getSprite9BackGround(); background->setContentSize(getContentSize()); background->setPosition(ccp(contentSize.width / 2, contentSize.height / 2)); this->addChild(background, 0, 0); } CCMenu* menu = CCMenu::createWithArray(mButtonArray); menu->setPosition(ccp(0,0)); addChild(menu); if (getLabelTitle()){ CCSize titleSize = getLabelTitle()->getContentSize(); getLabelTitle()->setPosition(ccp(contentSize.width/2, contentSize.height - titleSize.height/2)); this->addChild(getLabelTitle()); } CCAction* popupLayerAction = 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(popupLayerAction); }
void ArenaWindow::recv_3700() { Message *revMsg=(Message *)CData::getCData()->m_dictionary->objectForKey(3700); CData::getCData()->m_dictionary->removeObjectForKey(3700); if(revMsg) { load->removeFromParent(); this->unschedule(schedule_selector(ArenaWindow::recv_3700)); char* data=revMsg->data; CCLog("%s",data); Json::Reader read; Json::Value root; Json::Value jsonData; Json::Value petlist; if(read.parse(data, root)){ CCSprite* sp = CCSprite::create(); jsonData=root["data"]; petlist=jsonData["dsList"]; int sptimes = jsonData["sptimes"].asInt(); char titlechar[100] = ""; sprintf(titlechar, "当前排名:%d 今日挑战剩余次数:%d",jsonData["ranking"].asInt(),jsonData["sptimes"].asInt()); CCLabelTTF* titel = CCLabelTTF::create(titlechar, "hycc.ttf", 22,CCSizeMake(400, 0),kCCTextAlignmentCenter); titel->setColor(ccc3(255, 219, 160)); titel->setPosition(ccp(size.width/2, 600)); this->addChild(titel); int len = petlist.size(); for (int i=0; i<len; i++) { CCScale9Sprite* item = CCScale9Sprite::create("arena_item_bkg.png"); item->setContentSize(CCSizeMake(410, 85)); char rank[10] = ""; sprintf(rank, "%d",jsonData["dsList"][i]["ranking"].asInt()); CCLabelTTF* ranking = CCLabelTTF::create(rank, "hycc.ttf", 20,CCSizeMake(200, 0),kCCTextAlignmentCenter); //ranking->setColor(ccc3(255, 219, 160)); ranking->setPosition(ccp(37, 42)); item->addChild(ranking); CCLabelTTF* nickname = CCLabelTTF::create(jsonData["dsList"][i]["nickname"].asString().c_str(), "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft); nickname->setColor(ccc3(255, 219, 160)); nickname->setAnchorPoint(ccp(0, 0)); nickname->setPosition(ccp(85, 30)); item->addChild(nickname); char levelchar[10] = ""; sprintf(levelchar, "%d级",jsonData["dsList"][i]["level"].asInt()); CCLabelTTF* level = CCLabelTTF::create(levelchar, "hycc.ttf", 18,CCSizeMake(200, 0),kCCTextAlignmentLeft); level->setAnchorPoint(ccp(0, 0)); level->setColor(ccc3(255, 219, 160)); level->setPosition(ccp(180, 30)); item->addChild(level); if (sptimes != 0) { CCMenuItemImage* ok = CCMenuItemImage::create("arena_btn_bat_1.png", "arena_btn_bat_2.png", this, menu_selector(ArenaWindow::clk_battle)); ok->setTag(jsonData["dsList"][i]["characterId"].asInt()); CCMenu* menu = CCMenu::create(); menu->setAnchorPoint(ccp(0, 0)); menu->setPosition(ccp(370, 40)); menu->addChild(ok); item->addChild(menu); } CCSprite* qsbkg = CCSprite::create("common_qs_bkg_4.png"); qsbkg->setScale(1.0); int pro = jsonData["dsList"][i]["profession"].asInt(); char prochar[20] = ""; sprintf(prochar, "qs_%04d.png",pro); CCSprite* headsp = CCSprite::create(prochar); headsp->setScale(0.18); headsp->setAnchorPoint(ccp(0, 0)); qsbkg->addChild(headsp); qsbkg->setPosition(ccp(265, 38)); item->addChild(qsbkg); item->setAnchorPoint(ccp(0.5, 1)); item->setPosition(ccp(0,-i*82));//82 sp->addChild(item); } sp->setPosition(ccp(size.width/2, 560)); this->addChild(sp); } } }
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); }
void QuestionLayer::startAnswer() { timerCount = timerTotal; CCSize size = this->getContentSize(); CCLOG("%f %f", size.width, size.height); CCScale9Sprite* labelBg = CCScale9Sprite::create("bg_question.png"); labelBg->setAnchorPoint(ccp(0.5, 0.5)); labelBg->setPosition(ccp(0, size.height/2-100)); labelBg->setContentSize(CCSizeMake(size.width, 160)); this->addChild(labelBg, 0); const char* filePath = NULL; if (queType == SingleQuestion) { filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_4.plist").c_str(); } else if (queType == JudgeQuestion) { filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_2.plist").c_str(); } else { filePath = CCFileUtils::sharedFileUtils()->fullPathForFilename("question_3.plist").c_str(); } CCArray* plistArray = CCArray::createWithContentsOfFile(filePath); //开始查找随机题目,并且不能重复 bool bFind = false; while (!bFind) { serialNo = arc4random()%plistArray->count(); //serialNo = CCRANDOM_0_1()*plistArray->count()-1; CCLOG("serialNo:%d", serialNo); bool isSame = false; for (int i=0; i<historyQuestiones->count(); i++) { CCInteger* integer = (CCInteger *)historyQuestiones->objectAtIndex(i); if (integer->getValue() == serialNo) { isSame = true; break; } } if (!isSame) { bFind = true; } } historyQuestiones->addObject(CCInteger::create(serialNo)); CCDictionary* dic = (CCDictionary*)plistArray->objectAtIndex(serialNo); CCString* qType = (CCString *)(dic->objectForKey("type")); //Number类型 CCString* pStr = (CCString *)(dic->objectForKey("question")); CCLOG("%d %s", qType->intValue(), pStr->getCString()); CCArray* ans = (CCArray *)(dic->objectForKey("answer")); questionObj = new QuestionObj(qType->intValue(), pStr->getCString(), ans); CCLOG("读取题目信息完成"); questionString = questionObj->questionString; displayLen = 0; //题目 CCLabelTTF* pLabel = CCLabelTTF::create(questionStr.c_str(), "Arial", 24, CCSize(size.width-20, 90), kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop); pLabel->setAnchorPoint(ccp(1, 0)); pLabel->setPosition(ccp(-size.width/2+15, size.height/2-130)); pLabel->setAnchorPoint(ccp(0, 0)); this->addChild(pLabel, 1, 11); const char* typeStr = "单选题"; if (questionObj->questionType == 1) { typeStr = "单选题"; timerTotal = 15; } else if (questionObj->questionType == 2) { typeStr = "判断题"; timerTotal = 12; } else { typeStr = "多选题"; timerTotal = 30; } CCString* title = CCString::createWithFormat("题型:%s", typeStr); CCLabelTTF* label = CCLabelTTF::create(title->getCString(), "Arial", 24); label->setAnchorPoint(ccp(0, 1)); label->setPosition(ccp(140, size.height/2-135)); this->addChild(label, 1, 12); // CCSprite* timerBg = CCSprite::create("money_bg.png"); // timerBg->setPosition(ccp(0, size.height/2-200)); // this->addChild(timerBg); progressTimer = CCProgressTimer::create(CCSprite::create("money_bg.png")); progressTimer->setType(kCCProgressTimerTypeBar); progressTimer->setMidpoint(ccp(0, 0)); progressTimer->setBarChangeRate(ccp(1, 0)); progressTimer->setAnchorPoint(ccp(0.5, 0.5)); progressTimer->setPosition(ccp(0, size.height/2-200)); progressTimer->setPercentage(100); progressTimer->setContentSize(CCSizeMake(300, 38)); this->addChild(progressTimer, 2); timerLabel_ = CCLabelTTF::create(CCString::createWithFormat("%d", timerCount)->getCString(), "Arial", 24); timerLabel_->setAnchorPoint(ccp(1, 0)); timerLabel_->setPosition(ccp(0, 0)); progressTimer->addChild(timerLabel_); warnTipSpr = CCSprite::create("arrow000.png"); warnTipSpr->setPosition( ccp(progressTimer->getContentSize().width/3*2, 0) ); warnTipSpr->setAnchorPoint( ccp(0.5, 0) ); progressTimer->addChild(warnTipSpr); //显示宫格答案 this->displaySubViews(); this->schedule(schedule_selector(QuestionLayer::displayActionTimerCB), 0.05f); isAnswerFinished = false; // serialNo++; if (serialNo > plistArray->count()-1) { serialNo = 0; } propLayer_ = FightPropLayer::create(); propLayer_->setDelegate(this); propLayer_->setAnchorPoint( ccp(0.5, 0.5) ); propLayer_->setPosition( ccp(-size.width/2, -size.height/2) ); this->addChild(propLayer_, 100, 100); }
bool VVAlertView::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle) { if ( !VVPopupLayer::init() ) return false; delegate = aDelegate; overlayLayer->removeFromParentAndCleanup(true); CCLabelTTF *titleLabel = NULL; if( aTitle != NULL ) { titleLabel = CCLabelTTF ::labelWithString(aTitle ,fontName.c_str(), titleFontSize); } CCScale9Sprite *bg = CCScale9Sprite::scale9SpriteWithFile(alertBG_name.c_str(), alert9patch_rect); CCLabelTTF *msgLabel = CCLabelTTF::labelWithString(aMessage, CCSizeMake(maxWidth-borderPadding*4, 0), CCTextAlignmentCenter, fontName.c_str(), messageFontSize); CCMenuItemSprite* btnCancel = CCMenuItemDynamic::dynamicItemWithTTFLabel(aCancelBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this, menu_selector(VVAlertView::onBtnCancel), btn9patch_rect, 255); CCMenu *menu; if (aOtherBtnTitle == NULL) { menu = CCMenu::menuWithItems(btnCancel, NULL); } else { CCMenuItemSprite* btnOk = CCMenuItemDynamic::dynamicItemWithTTFLabel(aOtherBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this, menu_selector(VVAlertView::onBtnOk), btn9patch_rect, 255); menu = CCMenu::menuWithItems(btnCancel, btnOk, NULL); menu->alignItemsHorizontallyWithPadding(betweenBtnPadding); } menu->setTouchPriority(VVTouchPriorityMenuOnPopupLayer); addChild(bg); if (titleLabel) addChild(titleLabel); addChild(msgLabel); addChild(menu); if (titleLabel) totalHeight += titleLabel->getContentSize().height; totalHeight += msgLabel->getContentSize().height; totalHeight += btnCancel->getContentSize().height; totalHeight += centerPadding; totalHeight += messagePadding*2; totalHeight += borderPadding*2; float halfHeight = totalHeight/2; if (titleLabel) { titleLabel ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height/2)); // -15 : top padding msgLabel ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height - messagePadding - msgLabel->getContentSize().height/2 )); } else { msgLabel ->setPosition(ccp(0, halfHeight - borderPadding - msgLabel->getContentSize().height/2 )); } menu ->setPosition(ccp(0, -halfHeight + borderPadding + btnCancel->getContentSize().height/2)); bg->setContentSize(CCSizeMake(maxWidth, totalHeight)); // will be used for placing text field in the middle centerOfMargin = (msgLabel->getPosition().y + menu->getPosition().y)/2; return true; }
bool Scene_GameItem::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin(); //background // CCSprite* pSpriteBG = CCSprite::createWithSpriteFrameName("bg.png"); // pSpriteBG->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // pSpriteBG->setColor(ccGRAY); // by wsp // CCSprite* pSpriteBG = CCSprite::createWithSpriteFrameName("GameSceneBg/GameBg.png"); // pSpriteBG->setAnchorPoint(ccp(0.f,0.f)); CCScale9Sprite* pSpriteBG = CCScale9Sprite::create("./CocoStudioResources/GameSceneBg/GameBg.png"); pSpriteBG->setAnchorPoint(ccp(0.f,0.f)); pSpriteBG->setContentSize(CCSizeMake(visibleSize.width,visibleSize.height)); this->addChild(pSpriteBG, 0); pSpriteBG->setTag(eGameItemTagBg); CCSprite* pSpriteBGTop = CCSprite::create(); pSpriteBGTop->setTag(eGameItemTagBgTop); this->addChild(pSpriteBGTop, 0); ul = UILayer::create(); auto myLayout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile(CStringUtil::convertToUIResPath("Item.json").c_str())); ul->addWidget(myLayout); ul->setContentSize(visibleSize); this->addChild(ul, 1, 100); //返回按钮. returnBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("Return")); returnBtn->setPressedActionEnabled(true); returnBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::returnBtnCallBack)); //开始游戏按钮. UIButton* startGameBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("StartGame")); // startGameBtn->setPressedActionEnabled(true); startGameBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::startGameCallBack)); //道具按钮. UIButton* itemBtn1 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn1")); itemBtn1->setTag(Btn_1); itemBtn1->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack)); UIButton* itemBtn2 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn2")); itemBtn2->setTag(Btn_2); itemBtn2->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack)); UIButton* itemBtn3 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn3")); itemBtn3->setTag(Btn_3); itemBtn3->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack)); UIButton* itemBtn4 = dynamic_cast<UIButton*>(ul->getWidgetByName("ItemBtn4")); itemBtn4->setTag(Btn_4); itemBtn4->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::itemBtnCallBack)); //勋章任务点击. taskBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("TitleBtn")); taskBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::taskBtnCallBack)); taskBtn->setPressedActionEnabled(true); rankBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("RankingBtn")); rankBtn->addReleaseEvent(this, coco_releaseselector(Scene_GameItem::rankBtnCallBack)); rankBtn->setPressedActionEnabled(true); CTaskMan::sharedInstance().requestDayTaskSelect(GameShare_Global::shareGlobal()->gameType); //人物动画 auto pRole = CCSprite::create("role/pig_tl/1.png"); pRole->setTag(AniLayerTag); this->addChild(pRole,1); return true; }