本文整理汇总了C++中ImageView::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageView::getPosition方法的具体用法?C++ ImageView::getPosition怎么用?C++ ImageView::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageView
的用法示例。
在下文中一共展示了ImageView::getPosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool UIImageViewFlipTest::init()
{
if (UIScene::init())
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/blocks9ss.plist");
Size widgetSize = _widget->getContentSize();
Text* alert = Text::create("ImageView flip test", "fonts/Marker Felt.ttf", 26);
alert->setColor(Color3B(159, 168, 176));
alert->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f - alert->getContentSize().height * 2.125f));
_uiLayer->addChild(alert);
// Create the imageview
ImageView* imageView = ImageView::create("blocks9r.png", Widget::TextureResType::PLIST);
imageView->setScale9Enabled(true);
imageView->setContentSize(Size(250, 115));
imageView->setFlippedX(true);
imageView->setScale(0.5);
imageView->ignoreContentAdaptWithSize(false);
imageView->setPosition(Vec2(widgetSize.width / 2.0f,
widgetSize.height / 2.0f));
_uiLayer->addChild(imageView);
auto toggleButton = Button::create();
toggleButton->setTitleText("Toggle FlipX");
toggleButton->setPosition(imageView->getPosition() + Vec2(-50, - imageView->getContentSize().height/2 - 20));
this->addChild(toggleButton);
toggleButton->addClickEventListener([=](Ref*){
imageView->setFlippedX(!imageView->isFlippedX());
});
auto toggleScale9 = Button::create();
toggleScale9->setTitleText("Toggle Scale9");
toggleScale9->setPosition(imageView->getPosition() + Vec2(+50, - imageView->getContentSize().height/2- 20));
this->addChild(toggleScale9);
toggleScale9->addClickEventListener([=](Ref*){
imageView->setScale9Enabled(!imageView->isScale9Enabled());
//after switching scale9, you must call setContentSize to keep the size not change
imageView->setContentSize(Size(250, 115));
});
return true;
}
return false;
}
示例2: init
bool TalkDetailHelpLayer::init()
{
if(!Layer::init()) return false;
zPos = 0;
visibleSize = Director::getInstance()->getVisibleSize();
visibleSize.height -= 100;
ImageView* bgImage = ImageView::create("res/common/dlgback.png");
bgImage->setAnchorPoint(Vec2(0, 0));
bgImage->setPosition(Vec2(0, 0));
this->addChild(bgImage);
ImageView* helpTop = ImageView::create("res/talk/f_help_t.png");
helpTop->setAnchorPoint(Vec2(0, 0));
helpTop->setPosition(Vec2(0, visibleSize.height - 360));
this->addChild(helpTop);
ImageView* helpBottom = ImageView::create("res/talk/f_help_b.png");
helpBottom->setAnchorPoint(Vec2(0, 0));
helpBottom->setPosition(Vec2(0, 90));
this->addChild(helpBottom);
float profileX = (visibleSize.width - helpBottom->getContentSize().width)/2;
string str = "相手の好みに合った返信をすると好感度が貯まっていきます。\n♡色がピンクに染まったら相手はあなたに首ったけですよ。";
_topMessage = CCLabelTTF::create(str, kDEFAULT_BOLD_FONT, 26);
_topMessage->setColor(Color3B::BLACK);
_topMessage->setHorizontalAlignment(TextHAlignment::LEFT);
_topMessage->setAnchorPoint(Vec2(0, 0));
_topMessage->setPosition(Vec2(profileX + 40, helpTop->getPosition().y + 45));
_topMessage->setDimensions(Size(Vec2(visibleSize.width - 80, 0)));
this->addChild(_topMessage, zPos++);
str = "ここをタップで返信内容の選択肢が表示されます。\n相手に好印象を与える返信を選びましょう。\nあなたのテクニックの見せ所ですね。";
_bottomMessage = CCLabelTTF::create(str, kDEFAULT_BOLD_FONT, 26);
_bottomMessage->setColor(Color3B::BLACK);
_bottomMessage->setHorizontalAlignment(TextHAlignment::LEFT);
_bottomMessage->setAnchorPoint(Vec2(0, 0));
_bottomMessage->setPosition(Vec2(profileX + 40, helpBottom->getPosition().y + 70));
_bottomMessage->setDimensions(Size(Vec2(visibleSize.width - 80, 0)));
this->addChild(_bottomMessage, zPos++);
return true;
};
示例3: init
bool GamesScence::init()
{
if ( !Layer::init() )
{
return false;
}
m_blockSize = 20.0f;
m_isGgameRunning = false;
m_next3Tetrominos.clear();
Widget* pRootWidget = cocostudio::GUIReader::getInstance()->widgetFromJsonFile("TetrisUi/TetrisUi.ExportJson");
this->addChild(pRootWidget,0);
//最高分显示
m_highestLabel = (TextAtlas*)Helper::seekWidgetByName(pRootWidget,"atlHighest");
int highest = UserDefault::getInstance()->getIntegerForKey("TheHighestScore",0);
char strHighest[20];
sprintf(strHighest,"%d",highest);
m_highestLabel->setString(strHighest);
//分数显示
m_scoreCount.setNumberLabel((TextAtlas*)Helper::seekWidgetByName(pRootWidget,"atlScore"));
//提示消除了多少行
m_clearCount.setNumberLabel((TextAtlas*)Helper::seekWidgetByName(pRootWidget,"atlNumClear"));
//菜单按钮
m_btMenu = (Button*)Helper::seekWidgetByName(pRootWidget,"btMenu");
m_btMenu->addTouchEventListener(CC_CALLBACK_2(GamesScence::btMenuCallback,this));
//底板的纵横线
m_imgFrame = (ImageView*)Helper::seekWidgetByName(pRootWidget,"imgFrame");
//下一个方块的提示
ImageView* nextTip = (ImageView*)Helper::seekWidgetByName(pRootWidget,"imgTipBoard");
m_nextTipPos = nextTip->getPosition();
m_nextTipSize = nextTip->getContentSize();
//游戏菜单
m_panelManager.setMenuPanel((Layout*)Helper::seekWidgetByName(pRootWidget,"layMenu"));
m_panelManager.setMenuPanelVisible(false,true);
((Button*)Helper::seekWidgetByName(pRootWidget,"btStart"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btStartCallback,this));
((Button*)Helper::seekWidgetByName(pRootWidget,"btContinue"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btContinueCallback,this));
((Button*)Helper::seekWidgetByName(pRootWidget,"btRankList"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btRankListCallback,this));
((Button*)Helper::seekWidgetByName(pRootWidget,"btHelp"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btHelpCallback,this));
((Button*)Helper::seekWidgetByName(pRootWidget,"btLeave"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btLeaveCallback,this));
//GameOver菜单
m_panelManager.setGameOverPanel((Layout*)Helper::seekWidgetByName(pRootWidget,"layGameOver"));
m_panelManager.setGameOverPanelVisible(false);
((Button*)Helper::seekWidgetByName(pRootWidget,"btRestart"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btRestartCallback,this));
//上传分数面板
m_panelManager.setUploadScorePanel((Layout*)Helper::seekWidgetByName(pRootWidget,"layUploadScore"));
m_panelManager.setUploadScorePanelVisible(0,false);
m_nickNameInput = (TextField*)Helper::seekWidgetByName(pRootWidget,"tfNickName");
((Button*)Helper::seekWidgetByName(pRootWidget,"btConfirmation"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btConfirmationCallback,this));
((Button*)Helper::seekWidgetByName(pRootWidget,"btCancel"))->addTouchEventListener(CC_CALLBACK_2(GamesScence::btCancelCallback,this));
//排行榜(只是显示用,与服务器的交互放m_list里实现)
ListView* uilist = (ListView*)Helper::seekWidgetByName(pRootWidget,"listRankList");
m_panelManager.setRankList(uilist);
m_panelManager.setRankListVisible(false);
////真正与服务器交互的排行榜功能类
m_list = RankList::create(uilist);
this->addChild(m_list);
//游戏底板
Node* pFrame = Helper::seekWidgetByName(pRootWidget,"imgFrame");
Size frameSize = pFrame->getContentSize();
m_bgBpard = BackgroundBoard::create(m_blockSize);
m_bgBpard->setPosition(pFrame->getPosition());
m_bgBpard->setScaleX(frameSize.width/BACKGROUND_COL/m_blockSize);
m_bgBpard->setScaleY(frameSize.height/BACKGROUND_ROW/m_blockSize);
m_bgBpard->setDropDelayTime(0.5f);
m_bgBpard->setClearLineListener(this,clearLine_selector(GamesScence::onAddScore));
m_bgBpard->setNextBlockListener(this,nextBlock_selector(GamesScence::onNextBlock));
m_bgBpard->setGameOverListener(this,gameOver_selector(GamesScence::onGameOver));
Helper::seekWidgetByName(pRootWidget,"root")->addChild(m_bgBpard,0);
return true;
}
示例4: cocostudioTest
void SGTestScene::cocostudioTest()
{
Layout* panelUpdate = static_cast<Layout*>(GUIReader::shareReader()->widgetFromJsonFile("cocosUi/update_1.ExportJson"));
m_pUIGroup->addWidget(panelUpdate);
Layout* panelbg = NULL;
UIGet_Layout("Panel_bg", panelUpdate, panelbg)
//标签页通用
UIGet_Layout("Panel_jinjie", panelUpdate, mPanel_update[E_jinjie])
UIGet_Layout("Panel_qianghua", panelUpdate, mPanel_update[E_qianghua])
Layout* panelAtt;
UIGet_Layout("Panel_att", panelUpdate, panelAtt)
UIGet_Button("Button_qianghua", panelbg, mBtnUpdate[E_qianghua])
UIGet_Button("Button_jinjie", panelbg, mBtnUpdate[E_jinjie])
for (int i = E_qianghua; i < E_updateBtnMax; i ++)
{
UIClick(mBtnUpdate[i], SGTestScene::btnUpdate)
mBtnUpdate[i]->setTag(i);
mBtnUpdate[i]->setBrightStyle(BRIGHT_HIGHLIGHT); //按下的状态
UIbtnImgOff(mBtnUpdate[i])
mBtnUpdate[i]->setZOrder(1);
mPanel_update[i]->setVisible(false);
mPanel_update[i]->setEnabled(false);
}
//默认第一个标签页生效
mNowUpdateTag = E_qianghua;
mBtnUpdate[mNowUpdateTag]->setBrightStyle(BRIGHT_NORMAL);
UIbtnImgOn(mBtnUpdate[mNowUpdateTag])
mBtnUpdate[mNowUpdateTag]->setZOrder(4);
mPanel_update[mNowUpdateTag]->setVisible(true);
mPanel_update[mNowUpdateTag]->setEnabled(true);
mBtnUpdate[mNowUpdateTag]->setTouchEnabled(false);
//数值属性
ImageView* imgAtt[E_attributeMax];
ImageView *imgName, *imgLevel;
UIGet_ImageView("Image_fontBgGong", panelAtt, imgAtt[E_attack])
UIGet_ImageView("Image_fontBgFang", panelAtt, imgAtt[E_defense])
UIGet_ImageView("Image_fontBgXue", panelAtt, imgAtt[E_health])
UIGet_ImageView("Image_fontBgSu", panelAtt, imgAtt[E_speed])
UIGet_ImageView("Image_fontBgHero", panelAtt, imgLevel)
UIGet_ImageView("Image_nameBg", panelAtt, imgName)
for (int i = E_attack; i < E_attributeMax; i ++) {
mLabelAtt[i] = SGCCLabelTTF::create("34", FONT_PANGWA, 20, ccWHITE);
mLabelAtt[i]->setPosition(ccp(-40, -2));
imgAtt[i]->addNode(mLabelAtt[i]);
mLabelAttNew[i] = SGCCLabelTTF::create("45", FONT_PANGWA, 20, ccGrassGreen);
mLabelAttNew[i]->setPosition(ccp(70, -2));
imgAtt[i]->addNode(mLabelAttNew[i]);
}
mLabelLevel = SGCCLabelTTF::create("lv10", FONT_PANGWA, 20, ccWHITE);
mLabelLevel->setPosition(ccp(-40, -2));
imgLevel->addNode(mLabelLevel);
mLabelLevelNew = SGCCLabelTTF::create("lv11", FONT_PANGWA, 20, ccShitYellow);
mLabelLevelNew->setPosition(ccp(70, -2));
imgLevel->addNode(mLabelLevelNew);
mLabelName = SGCCLabelTTF::create("福岛正则", FONT_PANGWA, 26, ccWHITE);
mLabelName->setPosition(ccp(0, 0));
imgName->addNode(mLabelName);
//强化界面
ImageView* soulBarBg;
UIGet_ImageView("Image_loadingBg", mPanel_update[E_qianghua] , soulBarBg)
UIGet_LoadingBar("ProgressBar_qianghua", soulBarBg, mBarSoul)
mBarSoul->setPercent(90);
ImageView* soulFontBg;
UIGet_ImageView("Image_soulFontBg", mPanel_update[E_qianghua], soulFontBg)
mLabelSoulNum = SGCCLabelTTF::create("230000", FONT_PANGWA, 20, ccWHITE);
mPanel_update[E_qianghua]->addNode(mLabelSoulNum, 5);
mLabelSoulNum->setPosition(ccpAdd(soulFontBg->getPosition(), ccp(0, 0)));
Button *btnBack, *btnOK, *btnCancel, *btnAddSoul;
UIGet_Button("Button_back", mPanel_update[E_qianghua], btnBack)
UIGet_Button("Button_OK", mPanel_update[E_qianghua], btnOK)
UIGet_Button("Button_cancel", mPanel_update[E_qianghua], btnCancel)
UIGet_Button("Button_add", mPanel_update[E_qianghua], btnAddSoul)
mLabelSoulBar = SGCCLabelTTF::create(CCString::createWithFormat("%d/%d", 9, 10)->getCString(), FONT_PANGWA, 20, ccWHITE);
mBarSoul->addNode(mLabelSoulBar);
ImageView* imgQianghuaFontBg;
UIGet_ImageView("Image_qianghuaFontbg", mPanel_update[E_qianghua], imgQianghuaFontBg)
SGCCLabelTTF* labelQianghua0 = SGCCLabelTTF::create("强化需求:", FONT_PANGWA, 30, ccDarkOrange);
labelQianghua0->setPosition(ccpAdd(imgQianghuaFontBg->getPosition(), ccp(0, 45)));
mPanel_update[E_qianghua]->addNode(labelQianghua0);
SGCCLabelTTF* labelQianghua1 = SGCCLabelTTF::create("收集足够的灵魂石来强化武将", FONT_PANGWA, 26, CCSize(260,0), ccWHITE);
labelQianghua1->setPosition(ccpAdd(imgQianghuaFontBg->getPosition(), ccp(0, -5)));
mPanel_update[E_qianghua]->addNode(labelQianghua1);
//进阶界面
Button *btnJjBack, *btnJjJinjie;
UIGet_Button("Button_back", mPanel_update[E_jinjie], btnJjBack)
//.........这里部分代码省略.........