本文整理汇总了C++中UILayer类的典型用法代码示例。如果您正苦于以下问题:C++ UILayer类的具体用法?C++ UILayer怎么用?C++ UILayer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UILayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: movementEvent_selector
void HelloWorld::update(float delta)
{
if(m_bStart)
{
CCArmature *pHero = (CCArmature*)(m_pGameScene->getChildByTag(10005)->getComponent("CCArmature")->getNode());
pHero->getParent()->setPositionX(pHero->getParent()->getPositionX() + m_fSpeed);
CCArmature *pEnemy = (CCArmature*)(m_pGameScene->getChildByTag(10006)->getComponent("CCArmature")->getNode());
if(ccpDistance(ccp(pHero->getParent()->getPositionX(), 0), ccp(pEnemy->getParent()->getPositionX(), 0)) < m_fAttackDis)
{
pHero->getAnimation()->play("attack");
pHero->getAnimation()->setMovementEventCallFunc(this,
movementEvent_selector(HelloWorld::animationEvent));
m_bStart = false;
}
}
if(m_bDead)
{
CCComRender *pUIRender = static_cast<CCComRender*>(m_pGameScene->getChildByTag(10007)->getComponent("GUIComponent"));
UILayer *pUILayer = static_cast<UILayer*>(pUIRender->getNode());
UILoadingBar *pHPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("hp02_LoadingBar"));
UILoadingBar *pMPLoadingBar = static_cast<UILoadingBar*>(pUILayer->getWidgetByName("mp02_LoadingBar"));
pHPLoadingBar->setPercent(m_fPercentage);
pMPLoadingBar->setPercent(m_fPercentage);
m_fPercentage -= 2.0f;
if (m_fPercentage < 0.0f) {
unscheduleUpdate();
}
}
}
示例2: addChild
bool UIImageViewTest_Scale9::init()
{
if (UIScene::init())
{
CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
UILabel *alert = UILabel::create();
alert->setText("ImageView scale9 render");
alert->setFontName("Marker Felt");
alert->setFontSize(30);
alert->setColor(ccc3(159, 168, 176));
// alert->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f - alert->getRect().size.height * 1.75));
m_pUiLayer->addWidget(alert);
// Create the ui layer
UILayer *ul = UILayer::create();
ul->scheduleUpdate();
addChild(ul);
// Create the imageview
UIImageView *imageView = UIImageView::create();
imageView->setScale9Enabled(true);
imageView->loadTexture("cocosgui/buttonHighlighted.png");
// imageView->setScale9Size(CCSizeMake(200, 85));
// imageView->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f + imageView->getRect().size.height / 4.0f));
ul->addWidget(imageView);
return true;
}
return false;
}
示例3: S_ReqSyncTime
//--------------------------------------------------------------------------
/// <CODE-GENERATE>{GlobalClientFuncImpl}
void TexasPokerHallAgentC::C_RecLogin(const LoginResult& tResult)
{
/// <CODE-IMPLEMENT>{RecLogin}
if(tResult <= LOGIN_CREATE)
{
S_ReqSyncTime();
UILayer* pkMainLayer = g_pLayerManager->GetCurrentMainLayer();
if(!VeStrcmp(pkMainLayer->GetName(), Login::GetName()))
{
static_cast<Login*>(pkMainLayer)->IntoHall();
}
else
{
GetPlayer()->S_ReqInitHall();
UILayer* pkLayer = g_pLayerManager->GetCurrentMainLayer();
if(pkLayer)
{
pkLayer->OnForceUpdate();
}
}
}
else
{
g_pkGame->ShowAlert(VE_NEW HallLoginFailed(tResult));
}
/// </CODE-IMPLEMENT>{RecLogin}
}
示例4: menu_selector
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
/////////////////////////////
// 2. add a menu item with "X" image, which is clicked to quit the program
// you may modify it.
// add a "close" icon to exit the progress. it's an autorelease object
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"CloseNormal.png",
"CloseSelected.png",
this,
menu_selector(HelloWorld::menuCloseCallback));
pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
origin.y + pCloseItem->getContentSize().height/2));
// create menu, it's an autorelease object
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);
/////////////////////////////
// 3. add your codes below...
CCNode* gameScene = SceneReader::sharedSceneReader()->createNodeWithSceneFile("DemoCowboy.json");
addChild(gameScene);
//Create player
CCNode* playerNode = gameScene->getChildByTag(10004);
player = new Player(playerNode);
//Assign callbacks to the buttons
CCNode* uiNode = gameScene->getChildByTag(10005);
UILayer* ui = (UILayer*)uiNode->getComponent("GUIComponent")->getNode();
UIButton* btnLeft = (UIButton*)ui->getWidgetByName("LeftButton");
btnLeft->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveLeft));
UIButton* btnRight = (UIButton*)ui->getWidgetByName("RightButton");
btnRight->addTouchEventListener(this, toucheventselector(HelloWorld::onMoveRight));
UIButton* btnFire = (UIButton*)ui->getWidgetByName("FireButton");
// btnFire->addReleaseEvent(this, coco_releaseselector(HelloWorld::onFire));
btnFire->addTouchEventListener(this, toucheventselector(HelloWorld::onFire));
//Enable update loop
this->scheduleUpdate();
return true;
}
示例5: repaint
void UILabel::repaint(EngineInternals &internals, const UILayer &ui)
{
_elements.clear();
_elementPointers.clear();
_textures.clear();
float x = 0;
float y = 0;
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> convert;
std::wstring result = convert.from_bytes(_text);
Vector2 resolution(size.x * ui.getRatio(), size.y * ui.getRatio());
for (std::wstring::const_iterator i = result.begin(); i != result.end(); i++)
{
auto &g = _typeEngine.getGlyph(*i, (unsigned int)resolution.y);
float x2 = x + (float)g.bitmap.left;
float y2 = y + (resolution.y - (float)g.bitmap.top);
Texture2D *tex;
if (_textures.find(*i) != _textures.end())
{
tex = _textures[*i].get();
}
else
{
_textures[*i] = std::make_shared<Texture2D>(g.bitmap.buffer, Pixmap::Information(Metric2(g.bitmap.width, g.bitmap.height), Pixmap::Information::Format::ALPHA, 8));
tex = _textures[*i].get();
}
UIElement glyph = UIElement(Vector2((float)g.bitmap.width / ui.getRatio(), (float)g.bitmap.height / ui.getRatio()), Alignment::TOP_LEFT, Vector2(x2 / ui.getRatio(), y2 / ui.getRatio()), tex);
glyph.uvs[0] = Vector2(0, 0);
glyph.uvs[1] = Vector2(1, 0);
glyph.uvs[2] = Vector2(1, 1);
glyph.uvs[3] = Vector2(0, 1);
x += g.advance.x;
y += g.advance.y;
_elements.push_back(glyph);
}
for (auto &element : _elements)
{
_elementPointers.push_back(&element);
}
if (!_fixed)
{
size.x = x / ui.getRatio();
}
}
示例6: onEnter
// on "init" you need to initialize your instance
void GameLoginLayer::onEnter()
{
UILayer* uiLayer = UILayer::create();
uiLayer->scheduleUpdate();
UILayout* ui_root =dynamic_cast<UILayout*>(GUIReader::shareReader()->widgetFromJsonFile("plane_1.json"));
uiLayer->addWidget(ui_root);
UIButton *left_button = dynamic_cast<UIButton*>(uiLayer->getWidgetByName("TextButton_34"));
left_button->addReleaseEvent(this, SEL_ReleaseEvent(&GameLoginLayer::loginBtnCallback));
m_CCLayer->addChild(uiLayer);
}
示例7: UILayer
UILayer* UILayer::create(void)
{
UILayer *pRet = new UILayer();
if (pRet && pRet->init())
{
pRet->autorelease();
return pRet;
}
else
{
CC_SAFE_DELETE(pRet);
return NULL;
}
}
示例8: init
bool LoginScene::init()
{
if (!CCLayer::init()) {
return false;
}
UILayer* ui = UILayer::create();
ui->setTag(LOGIN_UI_TAG);
this->addChild(ui);
auto pUI = CCUIHELPER->createWidgetFromJsonFile("UI/DemoLogin/DemoLogin.json");
pUI->setTag(LOGIN_UI_WIDGET_TAG);
ui->addWidget(pUI);
auto pLoginBtn = dynamic_cast<UIButton*>(pUI->getChildByName("login_Button"));
pLoginBtn->addReleaseEvent(this, coco_releaseselector(LoginScene::loginRelease));
auto pCloseBtn = dynamic_cast<UIButton*>(pUI->getChildByName("close_Button"));
pCloseBtn->addReleaseEvent(this, coco_releaseselector(LoginScene::closeGame));
return true;
}
示例9: init
bool GestureScene::init() {
if ( !CCLayer::init() )
return false;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
this->setTouchEnabled(true);
UILayer* uiLayer = UILayer::create();
uiLayer->addWidget(GUIReader::shareReader()->widgetFromJsonFile("UI/GestureUI/GestureUI.json"));
UIPanel* rootPanel = (UIPanel*)uiLayer->getWidgetByName("rootPanel");
xLabel = (UILabel*) rootPanel->getChildByName("touchXLabel");
yLabel = (UILabel*) rootPanel->getChildByName("touchYLabel");
resultLabel = (UILabel*) rootPanel->getChildByName("gestureNameLabel");
this->addChild(uiLayer, 2);
return true;
}
示例10: CCLog
bool TestView::init(){
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
CCLog("winSize %f %f", size.width, size.height);
UILayer *lay = UILayer::create();
addChild(lay);
Widget *w = GUIReader::shareReader()->widgetFromJsonFile("testgui/LoginSence.json");
lay->addWidget(w);
w->setSizeType(SIZE_ABSOLUTE);
w->setSize(size);
return true;
}
示例11: DelLayer
void UILayerManager::DelLayer(const VeChar8* pcName)
{
if(pcName)
{
VeUInt32* it = m_kLayerMap.Find(pcName);
if(it)
{
VeUInt32 u32Index = *it;
if(u32Index < (m_kLayerSet.Size() - 1))
{
UILayer* pkLayer = m_kLayerSet[u32Index];
UILayer* pkMove = m_kLayerSet.Back();
m_kLayerMap[pkMove->GetName()] = u32Index;
m_kLayerSet[u32Index] = pkMove;
m_kLayerSet.Back() = pkLayer;
}
m_kLayerMap.Remove(pcName);
VE_SAFE_DELETE(m_kLayerSet.Back());
m_kLayerSet.PopBack();
}
}
}
示例12: switch
void Scene_GameItem::onEnter()
{
CCLayer::onEnter();
this->initData();
//隐藏pk界面
this->setPkView(false);
CCSprite* pSpriteBG = (CCSprite*)getChildByTag(eGameItemTagBg);
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
//pSpriteBG->setPosition(ccp(visibleSize.width/2 , pSpriteBG->getContentSize().height/2 + origin.y));
char str1[100]={0};
switch(GameShare_Global::shareGlobal()->gameType)
{
case 1:
sprintf(str1,"GameSceneBg1.json");
break;
case Game_Jelly:
sprintf(str1,"GameSceneBg2.json");
break;
case Game_Fruit:
sprintf(str1,"GameSceneBg3.json");
break;
case Game_Link:
sprintf(str1,"GameSceneBg4.json");
break;
case Game_TaiKo:
sprintf(str1,"GameSceneBg5.json");
break;
case Game_Cir:
sprintf(str1,"GameSceneBg1.json");
break;
default:
break;
}
UILayer* ul = UILayer::create();
auto myLayout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile(CStringUtil::convertToUIResPath(str1).c_str()));
ul->addWidget(myLayout);
this->addChild(ul, 0, 100);
ul->setTouchEnabled(false);
int nGameType = GameShare_Global::shareGlobal()->gameType;
if (nGameType==1)
{
UIImageView* pHill = dynamic_cast<UIImageView*>(ul->getWidgetByName("san"));
UIImageView* pHill2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("san2"));
//CCActionInterval* actionTo = CCScaleTo::create(2.0f, 0.5f);
CCActionInterval* actionBy = CCScaleBy::create(1.0f, 1.0f, 1.1f);
CCActionInterval* actionBy2 = CCScaleBy::create(1.0f, 1.1f, 1.0f);
CCFiniteTimeAction* seq = CCSequence::create(actionBy, actionBy->reverse(),NULL);
CCActionInterval * repeatForever =CCRepeatForever::create((CCActionInterval* )seq);
CCFiniteTimeAction* seq1 = CCSequence::create(actionBy2, actionBy2->reverse(),NULL);
CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq1);
pHill->runAction(repeatForever);
pHill2->runAction(repeatForever2);
}
else if (nGameType==2)
{
UIImageView* pCloud = dynamic_cast<UIImageView*>(ul->getWidgetByName("yun2"));
UIImageView* pCloud2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("yun3"));
CCActionInterval* actionBy = CCScaleBy::create(1.5f, 1.2f, 1.0f);
CCActionInterval* actionBy2 = CCScaleBy::create(1.5f, 1.2f, 1.0f);
CCFiniteTimeAction* seq1 = CCSequence::create(actionBy, actionBy->reverse(),NULL);
CCFiniteTimeAction* seq2 = CCSequence::create(actionBy2, actionBy2->reverse(),NULL);
CCActionInterval * repeatForever1 =CCRepeatForever::create((CCActionInterval* )seq1);
CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq2);
pCloud->runAction(repeatForever1);
pCloud2->runAction(repeatForever2);
}
else if (nGameType==3)
{
UIImageView* pSugar = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_15"));
UIImageView* pSugar1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_20"));
CCRotateBy* actionBy2 = CCRotateBy::create(1.5f, -25.0f, -25.0f);
CCRotateBy* actionBy1 = CCRotateBy::create(1.5f, -25.0f, -25.0f);
CCFiniteTimeAction* seq1 = CCSequence::create(actionBy2, actionBy2->reverse(), NULL);
CCFiniteTimeAction* seq2 = CCSequence::create(actionBy1, actionBy1->reverse(), NULL);
CCActionInterval * repeatForever1 =CCRepeatForever::create((CCActionInterval* )seq1);
CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq2);
pSugar->runAction(repeatForever1);
pSugar1->runAction(repeatForever2);
//星星
UIImageView* pXx1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_23"));
UIImageView* pXx2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_32"));
UIImageView* pXx3 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_35"));
UIImageView* pXx4 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Image_39"));
CCActionInterval* actionBy3 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
CCActionInterval* actionBy4 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
CCActionInterval* actionBy5 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
CCActionInterval* actionBy6 = CCScaleBy::create(1.2f, 1.3f, 1.3f);
CCFiniteTimeAction* seq3 = CCSequence::create(actionBy3, actionBy3->reverse(),NULL);
CCFiniteTimeAction* seq4 = CCSequence::create(actionBy4, actionBy4->reverse(),NULL);
CCFiniteTimeAction* seq5 = CCSequence::create(actionBy5, actionBy5->reverse(),NULL);
CCFiniteTimeAction* seq6 = CCSequence::create(actionBy6, actionBy6->reverse(),NULL);
//.........这里部分代码省略.........
示例13: ccp
bool GameLayerPk2::init()
{
if (!CCLayer::init()) {
return false;
}
UILayer* ul = UILayer::create();
auto myLayout = dynamic_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile(CStringUtil::convertToUIResPath("Pk2.json").c_str()));
ul->addWidget(myLayout);
this->addChild(ul, 0, 100);
UIButton* sureBtn = dynamic_cast<UIButton*>(ul->getWidgetByName("Sure"));
sureBtn->setPressedActionEnabled(true);
sureBtn->addReleaseEvent(this, coco_releaseselector(GameLayerPk2::sureBtnCallback));
//设置自己的头像.
UIImageView* cellBg = dynamic_cast<UIImageView*>(ul->getWidgetByName("Avatar1Bg"));
CCSprite* img = CCSprite::create();
img->setContentSize(CCSize(145, 145));
img->setAnchorPoint(ccp(0, 0));
cellBg->addRenderer(img, 10);
CImageDownloader::GetInstance()->SendHttpRequest(CPlayerInfoMan::sharedInstance().getPlayerInfo().strImg.c_str(), img, "1000", 1000);
//设置自己的名字
UILabel* nameLabel = dynamic_cast<UILabel*>(ul->getWidgetByName("Name1Label"));
nameLabel->setText(CPlayerInfoMan::sharedInstance().getPlayerInfo().strName.c_str());
//设置对方的头像
UIImageView* cellBg2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Avatar2Bg"));
CCSprite* img2 = CCSprite::create();
img2->setContentSize(CCSize(145, 145));
img2->setAnchorPoint(ccp(0, 0));
cellBg2->addRenderer(img2, 10);
CImageDownloader::GetInstance()->SendHttpRequest(CPkSysManager::sharedInstance().playerUrl.c_str(), img2, "1000", 1000);
//设置对方名字
UILabel* nameLabel2 = dynamic_cast<UILabel*>(ul->getWidgetByName("Name2Label"));
nameLabel2->setText(CPkSysManager::sharedInstance().playerName.c_str());
//设置自己的分数.
CCSprite* score = NumSprite::getNumSprite(CPkSysManager::sharedInstance().myScore, "./CocoStudioResources/FriendListTimeNum", 17.0);
score->setPosition(ccp(-35, 0));
UIImageView* scoreBg1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("ScoreBg"));
scoreBg1->addRenderer(score, 10);
//等待迎战;
m_iSetTime = 1;
Deng = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label1"));
Dai = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label2"));
Ying = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label3"));
Zhan = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label4"));
Dain1 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label5"));
Dain2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label6"));
Dain3 = dynamic_cast<UIImageView*>(ul->getWidgetByName("Label7"));
CCActionInterval* actionTo = CCJumpTo::create(2, ccp(200,200),50, 4);
CCActionInterval* actionBy = CCJumpBy::create(2, ccp(300,0), 50, 4);
actionUp = CCJumpBy::create(0.3f, ccp(0,0), 20,1);
CCActionInterval* actionByBack = actionUp->reverse();
//设置光效旋转
UIImageView* Ray2 = dynamic_cast<UIImageView*>(ul->getWidgetByName("lightimg"));
CCActionInterval * rotateto = CCRotateBy::create(6.0f, 360);
CCFiniteTimeAction* seq1 = CCSequence::create(rotateto,NULL);
CCActionInterval * repeatForever2 =CCRepeatForever::create((CCActionInterval* )seq1);
Ray2->runAction(repeatForever2);
//Deng->runAction( CCSequence::create(actionUp, NULL));
//Dai->runAction( CCSequence::create(actionUp, NULL));
// for(int i = 0;i<10;i++)
// {
// if(i%2==0)
// {
//
// Deng->runAction(actionByBack);
// }
// else{
//
// Dai->runAction(actionByBack);
// }
// }
//this->schedule(schedule_selector(GameLayerPk2::SetDDTime), 0.2f);
Deng->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Dai->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Ying->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Zhan->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Dain1->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Dain2->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
Dain3->runAction( CCSequence::create((CCActionInterval*)actionUp->copy(),NULL));
return true;
}
示例14: init
bool LayerBaCayAvatar::init()
{
if (!CCLayer::init()) return false;
myself = GameServer::getSingleton().getSmartFox()->MySelf();
UILayer *ul = UILayer::create();
this->myName = SceneManager::getSingleton().getMyName();
this->myAI = SceneManager::getSingleton().getMyName().c_str();
this->isSpector = GameServer::getSingleton().getSmartFox()->UserManager()->GetUserByName(myName)->IsSpectator();
btn_vaochoi = UIButton::create();
btn_vaochoi->setTouchEnabled(true);
btn_vaochoi->loadTextures("ready.png", "ready_selected.png", "");
btn_vaochoi->setTitleText("Vào bàn");
btn_vaochoi->setScale(0.8);
btn_vaochoi->setPosition(ccp(65,87));
btn_vaochoi->setTitleFontSize(20);
btn_vaochoi->addTouchEventListener(this,toucheventselector(LayerBaCayAvatar::vaoBanChoi));
btn_vaochoi->setEnabled(false);
btn_vaochoi->setTag(0);
btn_dungday = UIButton::create();
btn_dungday->setTouchEnabled(true);
btn_dungday->loadTextures("ready.png", "ready_selected.png", "");
btn_dungday->setTitleText("Đứng dậy");
btn_dungday->setScale(0.8);
btn_dungday->setPosition(ccp(65,87));
btn_dungday->setTitleFontSize(20);
btn_dungday->addTouchEventListener(this,toucheventselector(LayerBaCayAvatar::vaoBanChoi));
btn_dungday->setEnabled(false);
btn_dungday->setTag(1);
ul->addWidget(btn_dungday);
ul->addWidget(btn_vaochoi);
this->addChild(ul);
this->setAnchorPoint(ccp(0, 0));
this->setPosition(ccp(0, 0));
this->myName = SceneManager::getSingleton().getMyName();
Avatar *me = new Avatar(false);
// me->setTouchEnabled(false);
Avatar *user1 = new Avatar(false);
Avatar *user2 = new Avatar(false);
Avatar *user3 = new Avatar(false);
Avatar *user4 = new Avatar(false);
Avatar *user5 = new Avatar(false);
Avatar *user6 = new Avatar(false);
me->autorelease();
user1->autorelease();
user2->autorelease();
user3->autorelease();
user4->autorelease();
user5->autorelease();
user6->autorelease();
me->setPosition(ccp(WIDTH_DESIGN/2-me->getSizeThis().width/2+25,10));
user1->setPosition(ccp(40, 110));
user2->setPosition(ccp(40, HEIGHT_DESIGN-200));
user3->setPosition(ccp(250, 360));
user4->setPosition(ccp(WIDTH_DESIGN-320, 360));
user5->setPosition(ccp(WIDTH_DESIGN-120, HEIGHT_DESIGN-200));
user6->setPosition(ccp(WIDTH_DESIGN-120,110));
me->setTag(kuser0);
user1->setTag(kuser1);
user2->setTag(kuser2);
user3->setTag(kuser3);
user4->setTag(kuser4);
user5->setTag(kuser5);
user6->setTag(kuser6);
me->setScale(0.7);
user1->setScale(0.7);
user2->setScale(0.7);
user3->setScale(0.7);
user4->setScale(0.7);
user5->setScale(0.7);
user6->setScale(0.7);
this->addChild(me);
this->addChild(user1);
this->addChild(user2);
this->addChild(user3);
this->addChild(user4);
this->addChild(user5);
this->addChild(user6);
chuong = UIImageView::create();
chuong->loadTexture("Chuong.png");
chuong->setScale(0.7);
chuong->setTouchEnabled(false);
chuong->setVisible(false);
//.........这里部分代码省略.........
示例15: addChild
TanSuoLayer::TanSuoLayer()
{
m_nFontSize = 24;
m_nMaxCountDestroy = 3;
m_bIsJieFeng = false;
m_nSelectProId = -1;
mBg = BaseSprite::create("xunbao_bg.png");
addChild(mBg);
mBg->setPosition(ccp(mWinSize.width/2, mBg->getContentSize().height/2));
mMainMenu = CCMenu::create();
mBg->addChild(mMainMenu, 10);
mMainMenu->setPosition(ccp(0,0));
CCMenuItemImage *yijian = CCMenuItemImage::create(
"xunbao_anniu_yijianxunbao.png",
"xunbao_anniu_yijianxunbao_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
mMainMenu->addChild(yijian, 0, Tag_MenuItem_YiJianTanSuo);
yijian->setPosition(ccp(548,mBg->getContentSize().height-674));
Button *tansuo = Button::create();
tansuo->loadTextures("xunbao_anniu_xunbao.png","xunbao_anniu_xunbao_select.png","xunbao_anniu_xunbao_select.png",UI_TEX_TYPE_LOCAL);
/*CCMenuItemImage *tansuo = CCMenuItemImage::create(
"xunbao_anniu_xunbao.png",
"xunbao_anniu_xunbao_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));*/
tansuo->addTouchEventListener(this,SEL_TouchEvent(&TanSuoLayer::clickXunBao));
UILayer* layer = UILayer::create();
layer->ignoreAnchorPointForPosition(false);
layer->setContentSize(tansuo->getContentSize());
layer->setAnchorPoint(ccp(0.5,0.5));
layer->addWidget(tansuo);
layer->setPosition(320,mBg->getContentSize().height-674);//以前cpp(x,y) 现在左边 都是Point 比如颜色 ccWHITE 也改成了Color3B::WHITE
mBg->addChild(layer);
tansuo->setPosition(ccp(tansuo->getContentSize().width / 2 , tansuo->getContentSize().height / 2));
m_sXunBaoSpr = CCSprite::create("xunbao_anniu_xunbao_xiaoguo.png");
m_sXunBaoSpr->setPosition(ccp(320,mBg->getContentSize().height-674));
mBg->addChild(m_sXunBaoSpr);
m_sXunBaoSpr->runAction(CCRepeatForever::create(CCSequence::create(CCFadeOut::create(1.0f),CCFadeIn::create(1.0f),NULL)));
//mMainMenu->addChild(tansuo, 0, Tag_MenuItem_TanSuo);
//tansuo->setPosition(ccp(320,mBg->getContentSize().height-674));
{
CCMenuItemImage *jiefen = CCMenuItemImage::create(
"xunbao_anniu_jiechufengyin.png",
"xunbao_anniu_jiechufengyin_select.png",
this, menu_selector(TanSuoLayer::menuItemClicked_TanSuo));
mMainMenu->addChild(jiefen, 0, Tag_MenuItem_JieFen);
jiefen->setPosition(ccp(320,mBg->getContentSize().height-437));
jiefen->setVisible(false);
CCSprite *img = CCSprite::create("xunbao_anniu_jiechufengyin_xiaoguo.png");
jiefen->addChild(img);
img->setPosition(ccp(jiefen->getContentSize().width/2, jiefen->getContentSize().height/2));
img->runAction(CCRepeatForever::create(CCSequence::create(
CCFadeTo::create(1, 50), CCFadeTo::create(1, 255), NULL)));
}
mMainMenu->setVisible(false);
//title
CCLabelTTF *tilte = CCLabelTTF::create(LFStrings::getValue("XunBaoShuoMing").c_str(), fontStr_kaiti, m_nFontSize);
mBg->addChild(tilte);
tilte->setColor(fonColor_PuTong);
tilte->setPosition(ccp(mBg->getContentSize().width/2, mBg->getContentSize().height-110));
//2
CCLabelTTF *la1 = CCLabelTTF::create(LFStrings::getValue("XunBaoJieFeng").c_str(), fontStr_kaiti, m_nFontSize);
mBg->addChild(la1);
la1->setAnchorPoint(ccp(0, 0.5));
la1->setColor(fonColor_CiYao);
la1->setPosition(ccp(134, mBg->getContentSize().height-140));
CCLabelTTF *la2 = CCLabelTTF::create((LFStrings::getValue("shenbing")+LFStrings::getValue("zhuangbei")).c_str()
, fontStr_kaiti, m_nFontSize);
la1->addChild(la2);
la2->setColor(ImageManager::getManager()->getShowColor(ZhuangbeiColour_Chuanqi, false, false));
la2->setPosition(ccp(la1->getContentSize().width+la2->getContentSize().width/2, la1->getContentSize().height/2));
la1->setPositionX((mBg->getContentSize().width-la1->getContentSize().width-la2->getContentSize().width)/2);
}