本文整理汇总了C++中CCDirector::getVisibleSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCDirector::getVisibleSize方法的具体用法?C++ CCDirector::getVisibleSize怎么用?C++ CCDirector::getVisibleSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCDirector
的用法示例。
在下文中一共展示了CCDirector::getVisibleSize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MyPlane::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(!CCLayer::init());
// Create a plane (CCSprite)
// Current frame.
m_frame = 0;
m_bIsGameOver = false;
m_pPlane = CCPlane::createWithHPAndId(DEFAULT_HP, 0);
m_pPlane->initWithSpriteFrameName("ship03.png");
CCDirector *pDirector = CCDirector::sharedDirector();
m_pPlane->setPosition(ccp(pDirector->getVisibleSize().width / 2, 100));
this->addChild(m_pPlane);
this->schedule(schedule_selector(MyPlane::changePicture), 0.5f);
this->schedule(schedule_selector(MyPlane::shoot), 0.2f);
bRet = true;
} while (0);
return bRet;
}
示例2: 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;
}
示例3: init
bool ModalLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
CCSize visibleSize = pDirector->getVisibleSize();
CCSprite* frame = CCSprite::create("HelloWorld.png");
frame->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));
this->addChild(frame);
CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
"Send.png",
"SendHighlighted.png",
this,
menu_selector(ModalLayer::menuCloseCallback) );
pCloseItem->setPosition(ccp(
visibleSize.width/2+frame->getContentSize().width/2-pCloseItem->getContentSize().width/2-10,
visibleSize.height/2+frame->getContentSize().height/2-pCloseItem->getContentSize().height/2-10));
CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
pMenu->setPosition( CCPointZero );
this->addChild(pMenu);
return true;
}
示例4: applicationDidFinishLaunching
bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
CCDirector* pDirector = CCDirector::sharedDirector();
CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();
pDirector->setOpenGLView(pEGLView);
CCSize vs = pDirector->getVisibleSize();
// Set the design resolution
pEGLView->setDesignResolutionSize(vs.width, vs.height, kResolutionNoBorder);
CCSize frameSize = pEGLView->getFrameSize();
vector<string> searchPath;
// In this demo, we select resource according to the frame's height.
// If the resource size is different from design resolution size, you need to set contentScaleFactor.
// We use the ratio of resource's height to the height of design resolution,
// this can make sure that the resource's height could fit for the height of design resolution.
// if the frame's height is larger than the height of medium resource size, select large resource.
if (frameSize.height > mediumResource.size.height)
{
searchPath.push_back(largeResource.directory);
pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
}
// if the frame's height is larger than the height of small resource size, select medium resource.
else if (frameSize.height > smallResource.size.height)
{
searchPath.push_back(mediumResource.directory);
pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
}
// if the frame's height is smaller than the height of medium resource size, select small resource.
else
{
searchPath.push_back(smallResource.directory);
pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
}
// set searching path
CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);
// turn on display FPS
pDirector->setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
CCScene *pScene = HelloWorld::scene();
// run
pDirector->runWithScene(pScene);
return true;
}
示例5: init
void ResolutionUtil::init() {
__android_log_write(ANDROID_LOG_INFO, "ResolutionUtil", "ResolutionUtil init...");
CCDirector* director = CCDirector::sharedDirector();
CCSize size = director->getVisibleSize();
R_FACTOR = size.height / SCREEN_HEIGHT;
IMG_FACTOR = 1.0 * ResolutionUtil::R_FACTOR;
__android_log_print(ANDROID_LOG_INFO, "ResolutionUtil",
"getVisibleSize: %f * %f; R_FACTOR: %f; IMG_FACTOR: %f",
size.height, size.width, R_FACTOR, IMG_FACTOR);
}
示例6: init
bool MainMenuBarLayer::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
// Display Size
CCSize visibleSize = pDirector->getVisibleSize();
// Background Image for menu bar
CCScale9Sprite* scale9Sprite = CCScale9Sprite::create("frame_v.png");
scale9Sprite->setContentSize(ccp(visibleSize.width,visibleSize.height/10));
scale9Sprite->setPosition(ccp(visibleSize.width/2,visibleSize.height - scale9Sprite->getContentSize().height/2));
this->addChild(scale9Sprite,4);
// Go back to privious scene
CCMenuItemImage* menuBackItem = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
menuBackItem->setPosition(ccp(menuBackItem->getContentSize().width/2, visibleSize.height - menuBackItem->getContentSize().height/2));
CCMenu* menuBack = CCMenu::create(menuBackItem, NULL);
menuBack->setPosition(CCPointZero);
//this->addChild(menuBack);
// Send a message
CCMenuItemImage* sendItemImg = CCMenuItemImage::create("frame_g.png","frame_p.png",this,menu_selector(MainMenuBarLayer::goBackScene));
sendItemImg->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
CCMenu* menuSend = CCMenu::create(sendItemImg, NULL);
menuSend->setPosition(CCPointZero);
//this->addChild(menuSend);
// EditBox
CCEditBox* editBox;
CCSize editBoxSize = CCSizeMake(100, 100);
editBox = CCEditBox::create(editBoxSize, CCScale9Sprite::create("frame_g.png"));
editBox->setPosition(ccp(visibleSize.width - sendItemImg->getContentSize().width/2, visibleSize.height - sendItemImg->getContentSize().height/2));
editBox->setFontColor(ccBLUE);
editBox->setPlaceHolder("");
editBox->setMaxLength(100);
editBox->setFontSize(24);
editBox->setDelegate(this);
editBox->setTag(_EDITBOX_);
editBox->setInputMode(kEditBoxInputModeAny);
//editBox->setReturnType(kKeyboardReturnTypeSend);
this->addChild(editBox,5);
// End
return true;
}
示例7: move
void MyBullet::move(float dt)
{
CCDirector *pDirector = CCDirector::sharedDirector();
for (int i = 0; i < m_pArrayOfBullet->count(); )
{
CCBullet *pCurBullet = (CCBullet*)m_pArrayOfBullet->objectAtIndex(i);
pCurBullet->setPositionY(pCurBullet->getPositionY() + DEFAULT_SPEED);
if (pCurBullet->getPositionY() - pCurBullet->getContentSize().height / 2 > pDirector->getVisibleSize().height)
isOver(pCurBullet);
else
i++;
}
}
示例8: ccTouchMoved
void MyPlane::ccTouchMoved(CCTouch* touch, CCEvent* event){
if (m_bIsGameOver)
return;
CCPoint point = touch->getLocation();
CCDirector *pDirector = CCDirector::sharedDirector();
CCSize sizeOfVisible = pDirector->getVisibleSize();
CCPoint newPoint = CCPoint( max(0.0f,min(point.x, sizeOfVisible.width)), max(0.0f,min(point.y,sizeOfVisible.height)) );
m_pPlane->stopAllActions();
m_pPlane->setPosition(newPoint);
}
示例9: init
bool UpdateScene::init() {
CCScene::init();
CCDirector *pDirector = CCDirector::sharedDirector();
//背景黑框和屏幕一样大小
CCSprite *lm = CCSprite::create("black.png");
addChild(lm);
CCSize vs = pDirector->getVisibleSize();
lm->setPosition(ccp(vs.width/2, vs.height/2));
CCSize sz = lm->getContentSize();
lm->setScaleX(vs.width/sz.width);
lm->setScaleY(vs.height/sz.height);
CCLabelTTF *lab = CCLabelTTF::create("Loading...", "", 25);
lab->setColor(ccc3(255, 255, 255));
lab->enableShadow(CCSizeMake(1, 2), 1, 1, true);
lab->setAnchorPoint(ccp(0, 0.5));
lab->setPosition(ccp(16, 768-743));
addChild(lab);
CCSpriteFrameCache *sf = CCSpriteFrameCache::sharedSpriteFrameCache();
sf->addSpriteFramesWithFile("loadAni.plist");
CCAnimation *ani = CCAnimation::create();
char name[100];
for(int i = 0; i <= 20; i++) {
sprintf(name, "load%d.png", i);
ani->addSpriteFrame(sf->spriteFrameByName(name));
}
ani->setDelayPerUnit(2/20.0);
ani->setRestoreOriginalFrame(true);
CCSprite *cat = CCSprite::createWithSpriteFrameName("load0.png");
addChild(cat);
cat->setPosition(ccp(vs.width-228, 101));
cat->runAction(CCRepeatForever::create(CCAnimate::create(ani)));
updateYet = false;
scheduleUpdate();
nodeNum = 0;
return true;
}
示例10: loadPoint
//每10个百分点 增加1个点
void UpdateScene::loadPoint(int p) {
return;
CCDirector *pDirector = CCDirector::sharedDirector();
CCSize vs = pDirector->getVisibleSize();
int k = p/10;
int initX = 40;
int initY = vs.height-50;
int offX = 40;
while(k > nodeNum) {
CCLog("add Soldier");
CCSprite *s = CCSprite::create("soldier3.png");
s->setPosition(ccp(initX+offX*nodeNum, initY));
s->setScale(0.5);
addChild(s);
s->runAction(CCRepeatForever::create(CCSequence::create(CCMoveBy::create(0.3, ccp(5, 0)), CCMoveBy::create(0.3, ccp(-5, 0)), NULL)));
s->runAction(CCRepeatForever::create(CCSequence::create(CCRotateBy::create(0.4, -10), CCRotateBy::create(0.4, 10), NULL)));
nodeNum++;
}
}
示例11: init
bool FSAlertLayer::init()
{
// half clear black bgcolor
if (! CCLayerColor::initWithColor(ccc4(0, 0, 0, 100))) {
return false;
}
CCDirector* pDirector = CCDirector::sharedDirector();
pDirector->getTouchDispatcher()->addTargetedDelegate(this, kCCMenuHandlerPriority, true);
CCSize vsize = pDirector->getVisibleSize();
// bg
CCSprite* frame = CCSprite::create("dialog_yellow.png");
frame->setTag(FSAlertLayerTagFrame);
frame->setPosition(ccp(vsize.width / 2, vsize.height / 2));
this->addChild(frame);
return true;
}
示例12: 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;
}
示例13: 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;
}