bool CExpandableListViewBasicTest::init() { CExpandableListViewTestSceneBase::init(); setTitle("CExpandableListViewBasicTest"); setDescription("click item to expand"); pListView = CExpandableListView::create(CCSize(320, 390)); pListView->setBackgroundImage("background2.png"); pListView->setPosition(CCPoint(480, 320)); m_pWindow->addChild(pListView); for( int i = 0; i < 10; i++ ) { CExpandableNode* pExpandableNode = CExpandableNode::create(); pExpandableNode->setContentSize(CCSize(320, 50)); pListView->insertExpandableNodeAtLast(pExpandableNode); CImageViewScale9* pExpandableNodeBg = CImageViewScale9::create(CCSize(320, 45), "expandnodebg.png"); pExpandableNodeBg->setPosition(CCPoint(320/2, 50/2)); pExpandableNode->addChild(pExpandableNodeBg); CButton* pColBtn = CButton::createWith9Sprite(CCSize(35, 35), "sprite9_btn1.png", "sprite9_btn2.png"); pColBtn->setPosition(ccp(320 - 30, 50 / 2)); pColBtn->setText("-"); pColBtn->setUserTag(i); pColBtn->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick)); pExpandableNode->addChild(pColBtn); char buff[64] = {0}; sprintf(buff, "ExpandableNode : %d", i); CLabel* pTitleLabel = CLabel::create(buff, "", 28); pTitleLabel->setPosition(CCPoint(10, 50/2)); pTitleLabel->setAnchorPoint(CCPoint(0, 0.5)); pExpandableNode->addChild(pTitleLabel); sprintf(buff, "Label %d - 1", i); pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30)); sprintf(buff, "Label %d - 2", i); pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30)); sprintf(buff, "Label %d - 3", i); pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30)); CButton* pButton = CButton::createWith9Sprite(CCSize(150, 38), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick)); pButton->initText("collapse", "", 28); pButton->setUserTag(i); pButton->setPosition(CCPoint(100, 40/2)); CLayout* pBtnLayout = CLayout::create(CCSize(320, 40)); pBtnLayout->addChild(pButton); pExpandableNode->insertItemNodeAtLast(pBtnLayout); } pListView->reloadData(); return true; }
bool ViewScene::init(string unitid, string ziid, string curChar){ CCLog("ViewScene init"); if (!CCLayerColor::initWithColor(ccc4(255,255,255,255))) { return false; } this->unit_id = unitid; this->zi_id = ziid; this->currentChar = curChar; Notes = SQLiteData::getNote(unit_id,zi_id); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSize visiableSize = CCDirector::sharedDirector()->getVisibleSize(); CCSprite* titlebar = CCSprite::create("strangedesign/title bar_background.png"); addChild(titlebar); titlebar->setPosition(ccp(visiableSize.width/2,visiableSize.height-titlebar->getContentSize().height/2)); CWidgetWindow* m_pWindow = CWidgetWindow::create(); m_pWindow->setMultiTouchEnabled(true); addChild(m_pWindow); CButton* backBtn = CButton::create("strangedesign/back_button.png", "strangedesign/back_button_down.png"); backBtn->setOnClickListener(this,ccw_click_selector(ViewScene::back)); backBtn->setPosition(ccp(backBtn->getContentSize().width/2+10, visiableSize.height -backBtn->getContentSize().height/2-50)); m_pWindow->addChild(backBtn); CButton* deleteBtn = CButton::create("strangedesign/Free_writting_delete_button_up.png","strangedesign/Free_writting_delete_button_down.png"); deleteBtn->setOnClickListener(this, ccw_click_selector(ViewScene::deleteBtnClick)); deleteBtn->setPosition(ccp(winSize.width-deleteBtn->getContentSize().width/2, winSize.height-deleteBtn->getContentSize().height/2)); m_pWindow->addChild(deleteBtn); CCSize visualSize = CCSizeMake(winSize.width,winSize.height-titlebar->getContentSize().height-10); CCSize gridcellSize = CCSizeMake(360 , 350); writingCount = Notes.size(); pGridView = CGridView::create(visualSize, gridcellSize, writingCount, this, ccw_datasource_adapter_selector(ViewScene::gridViewDataSource)); pGridView->setColumns(2); pGridView->setPosition(CCSize(winSize.width/2,(winSize.height-titlebar->getContentSize().height)/2)); pGridView->setAutoRelocate(true); pGridView->reloadData(); m_pWindow->addChild(pGridView); return true; }
void CSharpTollgate::onEnter() { BaseLayer::onEnter(); CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onClose)); this->addChild(pClose, 999); m_cell = (CLayout*)(m_ui->findWidgetById("Cell")); // m_cell->retain(); // m_ui->removeChild(m_cell); CCAnimation *bgAnim = AnimationManager::sharedAction()->getAnimation("8055"); bgAnim->setDelayPerUnit(0.05f); CCSprite *bg = createAnimationSprite("skill/8055.png",VCENTER,bgAnim,true); bg->setScale(3.0f); m_ui->addChild(bg); m_tableView = (CTableView *)(m_ui->findWidgetById("scroll")); m_tableView->setDirection(eScrollViewDirectionHorizontal); m_tableView->setSizeOfCell(m_cell->getContentSize()); //m_tableView->setSizeOfCell(CCSizeMake(790,115)); m_tableView->setCountOfCell(0); m_tableView->setBounceable(false); m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CSharpTollgate::tableviewDataSource)); m_tableView->reloadData(); }
CCObject* CGridViewBasicTest::gridviewDataSource(CCObject* pConvertView, unsigned int idx) { CGridViewCell* pCell = (CGridViewCell*) pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(CCSizeMake(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(CCPoint(480 / 5 / 2, 320 / 4 / 2)); pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); return pCell; }
CCObject* CTableViewBindingDataAndVertical::tableviewDataSource(CCObject* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick)); pButton->setPosition(CCPoint(150.0f / 2, 54.0f / 2)); pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }
Ref* CTableViewReloadTest::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*) pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(150.0f / 2, 54.0f / 2)); // pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } pButton->getLabel()->setString(m_vDatas[idx].c_str()); pButton->setUserTag(idx); return pCell; }
Ref* CTableViewBasicTest::tableviewDataSource(Ref* pConvertView, unsigned int idx) { CTableViewCell* pCell = (CTableViewCell*)pConvertView; CButton* pButton = NULL; if(!pCell) { pCell = new CTableViewCell(); pCell->autorelease(); pButton = CButton::createWith9Sprite(Size(70, 70), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(74.0f / 2, 70.0f / 2)); //pButton->getLabel()->setFontSize(25.0f); pButton->setTag(1); pCell->addChild(pButton); } else { pButton = (CButton*) pCell->getChildByTag(1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); return pCell; }
bool CButtonChangeSizeTest::init() { CButtonTestSceneBase::init(); setTitle("CButtonChangeSizeTest"); setDescription("click the button for change anothor one"); m_lData.push_back("a"); m_lData.push_back("ab"); m_lData.push_back("abc"); m_lData.push_back("abcd"); m_lData.push_back("abcde"); m_lData.push_back("abcdef"); m_lData.push_back("abcdefg"); m_lData.push_back("abcdefgi"); m_lData.push_back("abcdefgj"); m_lData.push_back("hahahahaha\nhehehehehe"); m_lData.push_back("hahahahaha\nhehehehehe\nkukukukukukukuku"); m_pButton = CButton::create(); m_pButton->setScale9Enabled(true); m_pButton->setNormalImage("sprite9_btn1.png"); m_pButton->setSelectedImage("sprite9_btn2.png"); m_pButton->initText("none", "", 30.0f); m_pButton->setCascadeTextSizeEnabled(true, CCSize(50, 30)); m_pButton->setPosition(CCPoint(480, 320)); m_pWindow->addChild(m_pButton); CButton* pBtn = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pBtn->setPosition(CCPoint(250, 320)); pBtn->initText("click me", "", 27.0f); pBtn->setOnClickListener(this, ccw_click_selector(CButtonChangeSizeTest::onClick)); m_pWindow->addChild(pBtn); return true; }
void CSharpTollgate::addTableCell(unsigned int uIdx, CTableViewCell * pCell) { const vector<StageWidget> *data = DataCenter::sharedData()->getStageData() ->getStageWidgets(m_chapter); CStage &stage = m_stageList.at(uIdx); for (int i = 0; i < 2; i++) { CCNode * node = (CCNode*)m_cell->getChildren()->objectAtIndex(i); if (node->getTag()==1) { const StageWidget *widget = nullptr; CCString *strId = CCString::createWithFormat("hero%d",uIdx+1); for (int j=0; j<data->size();++j) { widget = &data->at(j); if (widget->widgetId!=""&&widget->widgetId.compare(strId->getCString())==0) { CButton *btn = CButton::create(widget->normalImage.c_str()); btn->setScaleX(widget->scaleX); btn->setScaleY(widget->scaleY); btn->setPosition(ccp(100, 80/*btn->boundingBox().size.height*/)); btn->setAnchorPoint(ccp(0.5, 0.0)); btn->setUserData(&m_stageList.at(uIdx)); btn->setOnClickListener(this,ccw_click_selector(CSharpTollgate::onBattle)); btn->setTag(1); pCell->addChild(btn); if (!stage.isOpen) { btn->getNormalImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone)); // btn->getSelectedImage()->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone)); } break; } } } else if (node->getTag()==2) { CImageView *image = UICloneMgr::cloneImageView((CImageView*)node); if (stage.star>0) { image->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("tollgate/star_%d.png",stage.star)->getCString())); } else { image->setTexture(CCTextureCache::sharedTextureCache()->addImage("tollgate/star_3.png")); image->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone)); } image->setAnchorPoint(ccp(0.5f,0)); pCell->addChild(image); } } pCell->setVisible(false); pCell->setScale(1.15f); pCell->runAction(CCSequence::create(CCDelayTime::create(0.1f+0.15f*uIdx),CCShow::create(),CCScaleTo::create(0.05f,1.0f),CCCallFuncN::create(this,callfuncN_selector(CSharpTollgate::heroCall)),nullptr)); }
bool CTableViewReloadTest::init() { CTableViewTestSceneBase::init(); setTitle("CTableViewReloadTest"); setDescription("click button will pop a string into vector and reload\n table with auto relocate"); m_lDataQueue.push_back("B"); m_lDataQueue.push_back("C"); m_lDataQueue.push_back("D"); m_lDataQueue.push_back("E"); m_lDataQueue.push_back("F"); m_lDataQueue.push_back("G"); m_lDataQueue.push_back("H"); m_lDataQueue.push_back("I"); m_lDataQueue.push_back("J"); m_lDataQueue.push_back("K"); m_lDataQueue.push_back("L"); m_lDataQueue.push_back("M"); m_lDataQueue.push_back("N"); m_lDataQueue.push_back("O"); m_lDataQueue.push_back("P"); m_lDataQueue.push_back("Q"); m_lDataQueue.push_back("R"); m_lDataQueue.push_back("S"); m_lDataQueue.push_back("T"); m_lDataQueue.push_back("U"); m_lDataQueue.push_back("V"); m_lDataQueue.push_back("W"); m_lDataQueue.push_back("X"); m_lDataQueue.push_back("Y"); m_lDataQueue.push_back("Z"); m_vDatas.push_back("A"); pTable = CTableView::create( Size(150.0f, 54.0f * 5), Size(150.0f, 54.0f), m_vDatas.size(), this, ccw_datasource_adapter_selector(CTableViewReloadTest::tableviewDataSource)); pTable->setDirection(eScrollViewDirectionVertical); pTable->setAutoRelocate(true); pTable->setPosition(Vec2(480, 320)); m_pWindow->addChild(pTable); pTable->reloadData(); CButton* pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setOnClickListener(this, ccw_click_selector(CTableViewReloadTest::onClick)); pButton->setPosition(Vec2(200, 320)); //pButton->getLabel()->setFontSize(25.0f); pButton->getLabel()->setString("reloadData"); m_pWindow->addChild(pButton); return true; }
bool CButtonBasicTest::init() { CButtonTestSceneBase::init(); setTitle("CButtonBasicTest"); setDescription("button by create"); CButton* pButton = CButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png"); pButton->setPosition(CCPoint(480, 320)); m_pWindow->addChild(pButton); return true; }
CButton* TuiManager::createBtn(float tag, Color3B color, int fontSize, const char* font, const char* lab, const char* normal, const char* select, const char* disable, float x, float y, float w, float h, float rotation, int isUseFrame){ CButton * pBtn = NULL; if(isUseFrame){ pBtn = CButton::createWith9SpriteFrameName(Size(w, h), normal, select, disable); }else{ pBtn = CButton::createWith9Sprite(Size(w,h),normal,select,disable); } if (lab) pBtn->initText(lab, font, fontSize, Size::ZERO, color); pBtn->setRotation(rotation); pBtn->setPosition(Vec2(x,-y)); pBtn->setTag(tag); return pBtn; }
CButton* TuiManager::createBtn(float tag, const char* normal,const char* select,const char* disable,float x,float y,float w, float h,float rotation){ CButton * pBtn = NULL; if(m_isUseSpriteFrame){ pBtn = CButton::create(); pBtn->setNormalSpriteFrameName(normal); pBtn->setSelectedSpriteFrameName(select); pBtn->setDisabledSpriteFrameName(disable); }else{ pBtn = CButton::createWith9Sprite(Size(w,h),normal,select,disable); } pBtn->setRotation(rotation); pBtn->setPosition(Point(x,-y)); pBtn->setTag(tag); return pBtn; }
void CVipCard::onEnter() { BaseLayer::onEnter(); //确定 CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm"); pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm)); CButton* cancel = (CButton*)m_ui->findWidgetById("cancel"); cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel)); CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CVipCard::onClose)); this->addChild(pClose, 999); CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1"); m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK); m_cardText->setPriority(this->getTouchPriority()); m_cardText->setLimitNum(17); m_cardText->setAnchorPoint(ccp(0, 0.5f)); m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY())); m_ui->addChild(m_cardText, 999); //展示区图片 CLayout *pShowInfo = CLayout::create(); CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info"); pScroll->setDirection(eScrollViewDirectionVertical); pScroll->setBounceable(false); pScroll->getContainer()->addChild(pShowInfo); CCSize size = CCSize(957, 471); pShowInfo->setContentSize(size); pScroll->setContainerSize(size); pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f)); pScroll->setContentOffsetToTop(); //嫁接内容 CLayout* pLayout = (CLayout*)findWidgetById("layer_info"); pLayout->retain(); pLayout->removeFromParent(); pShowInfo->addChild(pLayout); pLayout->release(); pLayout->setPosition(ccp(size.width/2, size.height/2+10)); }
bool CListViewOperateTest::init() { CListViewTestSceneBase::init(); setTitle("CListViewOperateTest"); setDescription("Add or Remove operate"); m_pListView = CListView::create(Size(480, 320)); m_pListView->setBackgroundImage("background.png"); m_pListView->setPosition(Vec2(480, 320)); m_pListView->setDirection(eScrollViewDirectionVertical); m_pWindow->addChild(m_pListView); CButton* pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(150, 450)); pButton->setUserTag(1); pButton->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick)); pButton->initText("Add Last", "", 30); m_pWindow->addChild(pButton); CButton* pButton2 = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton2->setPosition(Vec2(150, 380)); pButton2->setUserTag(2); pButton2->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick)); pButton2->initText("Add Front", "", 30); m_pWindow->addChild(pButton2); CButton* pButton3 = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton3->setPosition(Vec2(150, 310)); pButton3->setUserTag(3); pButton3->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick)); pButton3->initText("Remove Last", "", 30); m_pWindow->addChild(pButton3); CButton* pButton4 = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton4->setPosition(Vec2(150, 240)); pButton4->setUserTag(4); pButton4->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick)); pButton4->initText("Remove Front", "", 30); m_pWindow->addChild(pButton4); return true; }
void CSignLayer::onEnter() { BaseLayer::onEnter(); //签到grid的cell m_cell = (CLayout*)(m_ui->findWidgetById("Cell")); m_cell->retain(); m_ui->removeChild(m_cell); m_gridView = (CGridView*)m_ui->findWidgetById("scroll"); m_gridView->setDirection(eScrollViewDirectionVertical); m_gridView->setCountOfCell(0); m_gridView->setSizeOfCell(m_cell->getContentSize()); m_gridView->setAnchorPoint(ccp(0,0)); m_gridView->setColumns(5); m_gridView->setAutoRelocate(false); m_gridView->setDeaccelerateable(true); m_gridView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CSignLayer::gridviewDataSource)); m_gridView->reloadData(); m_signLay = (CLayout*)(m_ui->findWidgetById("Sign")); //退出 CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CSignLayer::onClose)); this->addChild(pClose, 999); //book CCheckBox* pBook = (CCheckBox*)(m_ui->findWidgetById("book")); pBook->setOnCheckListener(this,ccw_check_selector(CSignLayer::showHeroBook)); //按钮补签 CButton* pResign = (CButton*)m_ui->findWidgetById("buqian_btn"); pResign->setOnClickListener(this, ccw_click_selector(CSignLayer::onBtnResignDay)); //按钮签到 CButton* pSign = (CButton*)m_ui->findWidgetById("qiandao_btn"); pSign->setOnClickListener(this, ccw_click_selector(CSignLayer::onBtnSignDay)); GetTcpNet->registerMsgHandler(SignDataMsg,this, CMsgHandler_selector(CSignLayer::ProcessMsg)); GetTcpNet->registerMsgHandler(SignReqMsg,this, CMsgHandler_selector(CSignLayer::ProcessMsg)); }
bool CCheckBoxExclusionTest::init() { CCheckBoxTestSceneBase::init(); setTitle("CCheckBoxExclusionTest"); setDescription("checkbox exclusion test"); CREATE_CHECKBOX(pCheckBox1, CCPoint(480, 490)); pCheckBox1->setTag(1); pCheckBox1->setExclusion(1); pCheckBox1->setChecked(true); pCheckBox1->setEnabled(false); m_pWindow->addChild(pCheckBox1); CREATE_CHECKBOX(pCheckBox2, CCPoint(480, 425)); pCheckBox2->setExclusion(1); m_pWindow->addChild(pCheckBox2); CREATE_CHECKBOX(pCheckBox3, CCPoint(480, 360)); pCheckBox3->setExclusion(1); m_pWindow->addChild(pCheckBox3); CREATE_CHECKBOX(pCheckBox4, CCPoint(480, 295)); pCheckBox4->setExclusion(1); m_pWindow->addChild(pCheckBox4); CREATE_CHECKBOX(pCheckBox5, CCPoint(480, 230)); pCheckBox5->setExclusion(1); m_pWindow->addChild(pCheckBox5); CREATE_CHECKBOX(pCheckBox6, CCPoint(480, 165)); pCheckBox6->setExclusion(1); m_pWindow->addChild(pCheckBox6); CButton* pButton = CButton::createWith9Sprite(CCSize(280, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(CCPoint(200, 450)); pButton->setUserTag(1); pButton->setOnClickListener(this, ccw_click_selector(CCheckBoxExclusionTest::onClick)); pButton->initText("set true for first", "", 30); m_pWindow->addChild(pButton); return true; }
bool CListViewBasicTest::init() { CListViewTestSceneBase::init(); setTitle("CListViewBasicTest"); setDescription("ListView Test"); //test data tagItem tag1 = { Size(480, 10), Color3B::WHITE }; tagItem tag2 = { Size(480, 20), Color3B::RED }; tagItem tag3 = { Size(480, 30), Color3B::GREEN }; tagItem tag4 = { Size(100, 40), Color3B::ORANGE }; tagItem tag5 = { Size(480, 50), Color3B::MAGENTA }; tagItem tag6 = { Size(400, 60), Color3B::BLUE }; tagItem tag7 = { Size(300, 80), Color3B::RED }; tagItem tag8 = { Size(480, 30), Color3B::GRAY }; tagItem tag9 = { Size(480, 40), Color3B::YELLOW }; m_lDatas.push_back(tag1); m_lDatas.push_back(tag2); m_lDatas.push_back(tag3); m_lDatas.push_back(tag4); m_lDatas.push_back(tag5); m_lDatas.push_back(tag6); m_lDatas.push_back(tag7); m_lDatas.push_back(tag8); m_lDatas.push_back(tag9); //<< m_pListView = CListView::create(Size(480, 320)); m_pListView->setBackgroundImage("background.png"); m_pListView->setPosition(Vec2(480, 320)); m_pListView->setDirection(eScrollViewDirectionVertical); m_pWindow->addChild(m_pListView); CButton* pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(150, 320)); pButton->setOnClickListener(this, ccw_click_selector(CListViewBasicTest::onClick)); pButton->initText("Add", "", 30); m_pWindow->addChild(pButton); return true; }
bool CButton9SpriteTest::init() { CButtonTestSceneBase::init(); setTitle("CButton9SpriteTest"); setDescription("9PatchSprite by create"); CButton* pButton = CButton::createWith9Sprite(CCSize(196, 68),"sprite9_btn1.png", "sprite9_btn2.png"); pButton->initText("one", "", 30.0f); pButton->setPosition(CCPoint(480, 370)); m_pWindow->addChild(pButton); CButton* pButton2 = CButton::create(); pButton2->setContentSize(CCSize(196, 68)); pButton2->setScale9Enabled(true); pButton2->setNormalImage("sprite9_btn1.png"); pButton2->setSelectedImage("sprite9_btn2.png"); pButton2->initText("two", "", 30.0f); pButton2->setPosition(CCPoint(480, 270)); m_pWindow->addChild(pButton2); return true; }
void CHandBookPanel::onEnter() { BaseLayer::onEnter(); //选项卡 CRadioBtnGroup *radioGroup = (CRadioBtnGroup *)m_ui->findWidgetById("radio"); for (unsigned int i=0; i<HandBookTabMax; i++) { CRadioButton *radioBtn= (CRadioButton*)(radioGroup->getChildByTag(i)); radioBtn->setOnCheckListener(this,ccw_check_selector(CHandBookPanel::onSwitchBtn)); } //退出 CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CHandBookPanel::onClose)); this->addChild(pClose, 999); //默认选择一个 selectTabPanel(HandBookTabHero); }
void CStrengthenItem::onEnter() { BaseLayer::onEnter(); m_cell = (CLayout*)(m_ui->findWidgetById("Cell")); m_cell->retain(); m_ui->removeChild(m_cell); m_tableView = (CTableView *)(m_ui->findWidgetById("scroll")); m_tableView->setDirection(eScrollViewDirectionVertical); m_tableView->setSizeOfCell(m_cell->getContentSize()); m_tableView->setCountOfCell(0); m_tableView->setBounceable(false); m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CStrengthenItem::tableviewDataSource)); m_tableView->reloadData(); CButton *select = (CButton*)(m_ui->findWidgetById("select")); select->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onSelectItem)); CButton *filter = (CButton*)(m_ui->findWidgetById("filter")); filter->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onFilterItem)); //退出 CButton* pClose = CButton::create("common/back.png", "common/back.png"); pClose->getSelectedImage()->setScale(1.1f); pClose->setPosition(VLEFT+50, VTOP-50); pClose->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onClose)); this->addChild(pClose, 999); m_selectCellImg = (CCSprite*)m_ui->findWidgetById("selimg"); m_selectCellImg->retain(); GetTcpNet->registerMsgHandler(RoleBag,this,CMsgHandler_selector(CStrengthenItem::recItemData)); GetTcpNet->registerMsgHandler(ArmorListMsg,this,CMsgHandler_selector(CStrengthenItem::processNetMessage)); CSceneManager::sharedSceneManager()->addMsgObserver("updateFilter",this,GameMsghandler_selector(CStrengthenItem::onSetFilter)); }
CCObject* MainScene::gridviewDataSource(CCObject* pConvertView, unsigned int idx){ CGridViewCell* pCell = (CGridViewCell*) pConvertView; CButton* pButton = NULL; CCLog("idx %d",idx); if(!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pButton->getLabel()->setFontSize(40.0f); pButton->setTag(1); pCell->addChild(pButton,10); CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png"); sprite->setContentSize(CCSize(320,320)); sprite->setPosition(CCPoint(360/2,350/2)); pCell->addChild(sprite,1); CCLog("idx %d",idx); vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx)); CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280), ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200), ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120), ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40) }; for (unsigned int i = 0; i < groupCharacter.size(); i++) { string hanzi = groupCharacter.at(i).at(0); CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40); clabel->setPosition(positions[i]); clabel->setColor(ccc3(0,0,0)); sprite->addChild(clabel); } } else { pButton = CButton::create("strangedesign/main_clincher.png","strangedesign/main_clincher_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pButton->getLabel()->setFontSize(40.0f); pButton->setTag(1); pCell->addChild(pButton,10); CCSprite* sprite = CCSprite::create("strangedesign/table4mul4.png"); sprite->setContentSize(CCSize(320,320)); sprite->setPosition(CCPoint(360/2,350/2)); pCell->addChild(sprite,1); CCLog("idx %d",idx); vector<vector<string> > groupCharacter = SQLiteData::getUnit(unit_ids.at(idx)); CCPoint positions[16] = {ccp(40,280),ccp(120,280),ccp(200,280),ccp(280,280), ccp(40,200),ccp(120,200),ccp(200,200),ccp(280,200), ccp(40,120),ccp(120,120),ccp(200,120),ccp(280,120), ccp(40,40),ccp(120,40),ccp(200,40),ccp(280,40) }; for (unsigned int i = 0; i < groupCharacter.size(); i++) { string hanzi = groupCharacter.at(i).at(0); CCLabelTTF* clabel = CCLabelTTF::create(hanzi.c_str(),"Arial",40); clabel->setPosition(positions[i]); clabel->setColor(ccc3(0,0,0)); sprite->addChild(clabel); } } char buff[64]; unsigned int labelidx = idx+1; sprintf(buff, "%u", labelidx); pButton->getLabel()->setString(buff); pButton->setUserTag(idx); pButton->setOnClickListener(this,ccw_click_selector(MainScene::buttonClick)); pButton->setOnLongClickListener(this,ccw_longclick_selector(MainScene::buttonLongClick)); return pCell; }
bool CProgressBarBasicTest::init() { CProgressBarTestSceneBase::init(); setTitle("CProgressBarBasicTest"); setDescription("click the button to changed progress"); Sprite* m_pBg = Sprite::create("background.png"); m_pBg->setScale(1.3f); m_pBg->setPosition(Vec2(480, 320)); m_pWindow->addChild(m_pBg); m_pProgressBar = CProgressBar::create("progress.png"); m_pProgressBar->setBackgroundImage("progress_bg.png"); m_pProgressBar->setPosition(Vec2(480, 320)); m_pProgressBar->setMaxValue(100); m_pProgressBar->setMinValue(0); m_pProgressBar->setDirection(eProgressBarDirectionLeftToRight); m_pProgressBar->setOnValueChangedListener( this, ccw_valuechanged_selector(CProgressBarBasicTest::onProgressing)); m_pProgressBar->setContentSize(Size(960, 640)); m_pWindow->addChild(m_pProgressBar); CButton* pButton = CButton::createWith9Sprite(Size(150, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(250, 450)); pButton->setUserTag(1); pButton->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick)); pButton->initText("Add", "", 30); m_pWindow->addChild(pButton); CButton* pButton2 = CButton::createWith9Sprite(Size(150, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton2->setPosition(Vec2(450, 450)); pButton2->setUserTag(2); pButton2->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick)); pButton2->initText("Less", "", 30); m_pWindow->addChild(pButton2); CButton* pButton3 = CButton::createWith9Sprite(Size(200, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton3->setPosition(Vec2(670, 450)); pButton3->setUserTag(3); pButton3->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick)); pButton3->initText("change direction", "", 30); m_pWindow->addChild(pButton3); CButton* pButton4 = CButton::createWith9Sprite(Size(150, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton4->setPosition(Vec2(350, 200)); pButton4->setUserTag(4); pButton4->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick)); pButton4->initText("startProgress", "", 30); pButton4->setCascadeTextSizeEnabled(true, Size(50, 30)); m_pWindow->addChild(pButton4); CButton* pButton5 = CButton::createWith9Sprite(Size(150, 60), "sprite9_btn1.png", "sprite9_btn2.png"); pButton5->setPosition(Vec2(650, 200)); pButton5->setUserTag(5); pButton5->setOnClickListener(this, ccw_click_selector(CProgressBarBasicTest::onClick)); pButton5->initText("stopProgress", "", 30); pButton5->setCascadeTextSizeEnabled(true, Size(50, 30)); m_pWindow->addChild(pButton5); m_pText = CLabel::create(); m_pText->setAnchorPoint(Vec2(0, 0.5)); m_pText->setPosition(Vec2(200, 400)); //m_pText->setFontSize(35.0f); m_pText->setString("none"); m_pWindow->addChild(m_pText); return true; }
void CListViewOperateTest::onClick(Ref* pSender) { CButton* pButton = (CButton*) pSender; switch(pButton->getUserTag()) { case 1: { CLayout* pLayout = CLayout::create(); pLayout->setContentSize(Size(480, 30)); /* CColorView* pColor = CColorView::create(Color4B(128, 0, 0, 255)); pColor->setContentSize(Size(478, 28)); pColor->setPosition(Point(480/2, 30/2)); pLayout->addChild(pColor); */ CButton* pButton = CButton::createWith9Sprite(Size(150, 25), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(480 /2, 30 /2)); char str[64] = {0}; sprintf(str, "%d", last_add_idx); pButton->initText(str, "", 20); pLayout->addChild(pButton); last_add_idx++; m_pListView->insertNodeAtLast(pLayout); m_pListView->reloadData(); } break; case 2: { CLayout* pLayout = CLayout::create(); pLayout->setContentSize(Size(480, 30)); /* CColorView* pColor = CColorView::create(Color4B(0, 128, 0, 255)); pColor->setContentSize(Size(478, 28)); pColor->setPosition(Point(480/2, 30/2)); pLayout->addChild(pColor); */ CButton* pButton = CButton::createWith9Sprite(Size(150, 25), "sprite9_btn1.png", "sprite9_btn2.png"); pButton->setPosition(Vec2(480 /2, 30 /2)); char str[64] = {0}; sprintf(str, "%d", last_add_idx); pButton->initText(str, "", 20); pLayout->addChild(pButton); last_add_idx++; m_pListView->insertNodeAtFront(pLayout); m_pListView->reloadData(); } break; case 3: { m_pListView->removeLastNode(); m_pListView->reloadData(); } break; case 4: { m_pListView->removeFrontNode(); m_pListView->reloadData(); } break; default: break; } }
CCObject* ViewScene::gridViewDataSource(CCObject* pContentView, unsigned int idx){ CGridViewCell* pCell = (CGridViewCell*) pContentView; CButton* pButton = NULL; CCheckBox* pCheckbox = NULL; Notes = SQLiteData::getNote(unit_id,zi_id); vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列 if (!pCell) { pCell = new CGridViewCell(); pCell->autorelease(); pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pCheckbox = CCheckBox::create(); pCheckbox->setNormalImage("ckb_normal_01.png"); pCheckbox->setNormalPressImage("ckb_normal_02.png"); pCheckbox->setCheckedImage("ckb_selected_01.png"); pCheckbox->setCheckedPressImage("ckb_selected_02.png"); pCheckbox->setDisabledNormalImage("ckb_disable_01.png"); pCheckbox->setDisabledCheckedImage("ckb_disable_02.png"); pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2)); pCell->addChild(pCheckbox,10); //pCell->addChild(pButton,10); HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create(); vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1)); for (unsigned int i = 0; i < strokesvec.size(); i++) { vector<CCPoint> oneStrokeVec = strokesvec[i]; Stroke stroke(oneStrokeVec); handwritingHz->addStroke(stroke); } handwritingHz->setContentSize(CCSize(320,320)); CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2); handwritingHz->setPosition(position); pCell->addChild(handwritingHz,1); }else { pButton = CButton::create("strangedesign/Dlg_cancel_button.png","strangedesign/Dlg_cancel_button_down.png"); pButton->setPosition(CCPoint(360/2, 350-pButton->getContentSize().height/2)); pCheckbox = CCheckBox::create(); pCheckbox->setNormalImage("ckb_normal_01.png"); pCheckbox->setNormalPressImage("ckb_normal_02.png"); pCheckbox->setCheckedImage("ckb_selected_01.png"); pCheckbox->setCheckedPressImage("ckb_selected_02.png"); pCheckbox->setDisabledNormalImage("ckb_disable_01.png"); pCheckbox->setDisabledCheckedImage("ckb_disable_02.png"); pCheckbox->setPosition(CCPoint(360-pCheckbox->getContentSize().width, 350-pButton->getContentSize().height/2)); pCell->addChild(pCheckbox,10); //pCell->addChild(pButton,10); HcharacterDrawnode* handwritingHz = HcharacterDrawnode::create(); vector<string> oneNote = Notes.at(idx); //oneNote 中第一个元素为ID,第二个元素为笔画序列 vector< vector<CCPoint> > strokesvec = DataTool::spliteString(oneNote.at(1)); for (unsigned int i = 0; i < strokesvec.size(); i++) { vector<CCPoint> oneStrokeVec = strokesvec[i]; Stroke stroke(oneStrokeVec); handwritingHz->addStroke(stroke); } handwritingHz->setContentSize(CCSize(320,320)); CCPoint position = ccp(360/2- handwritingHz->getContentSize().width/2, 350/2- handwritingHz->getContentSize().height/2); handwritingHz->setPosition(position); pCell->addChild(handwritingHz,1); } char buff[64]; sprintf(buff, "%u", idx); pButton->getLabel()->setString(buff); int userTag = DataTool::stringToInt(oneNote.at(0)); pButton->setUserTag(userTag); pCheckbox->setUserTag(userTag); pButton->setOnClickListener(this,ccw_click_selector(ViewScene::buttonClick)); pCheckbox->setOnClickListener(this,ccw_click_selector(ViewScene::checkBoxClick)); return pCell; }