本文整理汇总了C++中CCDirector::getVisibleOrigin方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getVisibleOrigin方法的具体用法?C++ CCDirector::getVisibleOrigin怎么用?C++ CCDirector::getVisibleOrigin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDirector
的用法示例。
在下文中一共展示了CCDirector::getVisibleOrigin方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool HelpScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
setKeypadEnabled(true);
LayoutManager *layoutManager = LayoutManager::getInstance();
CCRect visibleRect = layoutManager->getVisibleRect();
CCDirector *director = CCDirector::sharedDirector();
m_Background = CCSprite::create("help.png");
m_Background->retain();
m_Background->setPosition(director->getVisibleOrigin() + director->getVisibleSize() / 2);
addChild(m_Background);
CCMenuItemImage *pBack = CCMenuItemImage::create("back.png", NULL, this, menu_selector(HelpScene::backCallback));
pBack->setAnchorPoint(CCPointZero);
pBack->setPosition(ccp(visibleRect.origin.x + 18, visibleRect.origin.y + 12));
CCMenu *pMenu = CCMenu::create(pBack, NULL);
pMenu->setAnchorPoint(CCPointZero);
pMenu->setPosition(CCPointZero);
addChild(pMenu);
return true;
}
示例2: init
bool MPTitleLayer::init()
{
CCDirector * director = CCDirector::sharedDirector();
CCPoint origin = director->getVisibleOrigin();
float h = director->getVisibleSize().height;
float w = director->getVisibleSize().width;
// CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
// CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
// Scene title
CCLabelTTF * pLabel = CCLabelTTF::create("Title Scene", "Arial", TITLE_FONT_SIZE);
pLabel->setPosition(
ccp(origin.x + w/2, origin.y + h - pLabel->getContentSize().height)
);
this->addChild(pLabel, 1);
// Layout the selectable labels.
int yInc = 70;
int xPos = w/2;
int yPos = h - 2* yInc;
// Box2D menu item label
CCLabelTTF * box2DLabel = CCLabelTTF::create("Box 2D Scene", "Arial", TITLE_FONT_SIZE);
box2DLabel->setPosition(CCPointZero);
CCMenuItemLabel * box2DItem =
CCMenuItemLabel::create(box2DLabel, this, menu_selector(MPTitleLayer::selectBox2D));
box2DItem->setPosition(xPos, yPos);
// GUI Test menu item label
yPos -= yInc;
CCLabelTTF * guiTestLabel = CCLabelTTF::create("GUI Test Scene", "Arial", TITLE_FONT_SIZE);
guiTestLabel->setPosition(CCPointZero);
CCMenuItemLabel * guiTestItem =
CCMenuItemLabel::create(guiTestLabel, this, menu_selector(MPTitleLayer::selectGuiTest));
guiTestItem->setPosition(xPos, yPos);
// Audio Button
yPos -= yInc;
CCLabelTTF * audioLabel = CCLabelTTF::create("Audio Scene", "Arial", TITLE_FONT_SIZE);
audioLabel->setPosition(CCPointZero);
CCMenuItemLabel * audioItem =
CCMenuItemLabel::create(audioLabel, this, menu_selector(MPTitleLayer::selectAudio));
audioItem->setPosition(xPos, yPos);
// Map Button
yPos -= yInc;
CCLabelTTF * mapLabel = CCLabelTTF::create("Map Scene", "Arial", TITLE_FONT_SIZE);
mapLabel->setPosition(CCPointZero);
CCMenuItemLabel * mapItem =
CCMenuItemLabel::create(mapLabel, this, menu_selector(MPTitleLayer::selectMap));
mapItem->setPosition(xPos, yPos);
// Turner Map Button
yPos -= yInc;
CCLabelTTF* turnerMapLabel = CCLabelTTF::create("Turner Map Scene", "Arial", TITLE_FONT_SIZE);
turnerMapLabel->setPosition(CCPointZero);
CCMenuItemLabel * turnerMapItem =
CCMenuItemLabel::create(turnerMapLabel, this, menu_selector(MPTitleLayer::selectTurnerMap));
turnerMapItem->setPosition(xPos, yPos);
// Close button
CCMenuItemImage * closeItem =
CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png", this, menu_selector(MPTitleLayer::menuCloseCallback));
closeItem->setPosition(
ccp( origin.x + w - closeItem->getContentSize().width/2 ,
origin.y + closeItem->getContentSize().height/2
)
);
// Menu container
CCMenu * menu = CCMenu::create(box2DItem, guiTestItem, audioItem, mapItem, turnerMapItem, closeItem, NULL);
menu->setPosition(CCPointZero);
this->addChild(menu, 1);
return true;
}
示例3: init
bool ChoosePackageScene::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
setKeypadEnabled(true);
CCDirector *director = CCDirector::sharedDirector();
LayoutManager *layoutManager = LayoutManager::getInstance();
CCRect visibleRect = layoutManager->getVisibleRect();
m_Background = CCSprite::create("bg_common.jpg");
m_Background->retain();
m_Background->setPosition(director->getVisibleOrigin() + director->getVisibleSize() / 2);
addChild(m_Background);
CCSprite *sprite = CCSprite::create("stage_select.png");
sprite->setPosition(ccp(visibleRect.origin.x + visibleRect.size.width / 2, 630));
addChild(sprite);
// Create the page view
int pageViewHeight = 556;
int pageWidth = 336;
LGPageView *pageView = LGPageView::create();
pageView->setTouchEnabled(true);
pageView->setSize(CCSizeMake(visibleRect.size.width, pageViewHeight));
pageView->setPosition(CCSizeMake(visibleRect.origin.x, + visibleRect.origin.y + (visibleRect.size.height - pageViewHeight) / 2));
pageView->setPageWidth(pageWidth);
pageView->setIndicatorEnable(true);
StageManager *stageManager = StageManager::getInstance();
for (int i = 0; i < sizeof(PACKAGE_IMAGE) / sizeof(PACKAGE_IMAGE[0]); ++i)
{
Layout *layout = Layout::create();
layout->setSize(CCSizeMake(pageWidth, pageView->getSize().height));
UIImageView *imageView = UIImageView::create();
imageView->loadTexture(PACKAGE_IMAGE[i]);
imageView->setPosition(ccp(layout->getRect().size.width / 2, layout->getRect().size.height / 2));
imageView->setTag(i);
imageView->addReleaseEvent(this, coco_releaseselector(ChoosePackageScene::selectPackageCallback));
imageView->setTouchEnabled(true);
layout->addChild(imageView);
ccFontDefinition strokeTextDef;
strokeTextDef.m_fontSize = 100;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
strokeTextDef.m_fontName = "Lithograph";
#else
strokeTextDef.m_fontName = "fonts/Lithograph.ttf";
#endif
strokeTextDef.m_stroke.m_strokeEnabled = true;
strokeTextDef.m_stroke.m_strokeColor = LayoutManager::getInstance()->DefaultStroke;
strokeTextDef.m_stroke.m_strokeSize = 30;
strokeTextDef.m_fontFillColor = ccWHITE;
CCLabelTTF *labelStage = CCStrokeLabel::createWithFontDefinition(CCString::createWithFormat(" %d ", (i + 1))->getCString(), strokeTextDef);
labelStage->setPosition(ccp(layout->getRect().size.width / 2, layout->getRect().size.height / 2));
layout->addCCNode(labelStage);
strokeTextDef.m_fontSize = 40;
strokeTextDef.m_stroke.m_strokeSize = 16;
CCLabelTTF *labelCompletion = CCStrokeLabel::createWithFontDefinition(CCString::createWithFormat(" %d/%d ", stageManager->getCompletedStageCount(i), stageManager->getStageCount(i))->getCString(), strokeTextDef);
labelCompletion->setPosition(ccp(layout->getRect().size.width / 2, layout->getRect().size.height / 2 - labelStage->getContentSize().height / 2 - labelCompletion->getContentSize().height / 2));
layout->addCCNode(labelCompletion);
m_LabelCompletions->addObject(labelCompletion);
pageView->addPage(layout);
}
UILayer *pUiLayer = UILayer::create();
pUiLayer->addWidget(pageView);
addChild(pUiLayer);
pUiLayer->scheduleUpdate();
CCMenuItemImage *pBack = CCMenuItemImage::create("back.png", NULL, this, menu_selector(ChoosePackageScene::backCallback));
pBack->setAnchorPoint(CCPointZero);
pBack->setPosition(ccp(visibleRect.origin.x + 18, visibleRect.origin.y + 12));
CCMenu *pMenu = CCMenu::create(pBack, NULL);
pMenu->setAnchorPoint(CCPointZero);
pMenu->setPosition(CCPointZero);
addChild(pMenu);
return true;
}