本文整理汇总了C++中CCLayer::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLayer::setScale方法的具体用法?C++ CCLayer::setScale怎么用?C++ CCLayer::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLayer
的用法示例。
在下文中一共展示了CCLayer::setScale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLayerMessageBox
void AssetsUpdateLayer::updateLayerMessageBox()
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ccb/ccbResources/SystemLoading.plist");
CCLayer* layer = CCLayer::create();
layer->ignoreAnchorPointForPosition(false);
layer->setContentSize(Size(960, 640));
layer->setPosition(Point(Director::getInstance()->getWinSize().width * 0.5, Director::getInstance()->getWinSize().height * 0.5));
layer->setScale(Director::getInstance()->getWinSize().width / 960);
addChild(layer, 1);
Sprite* messageboxSprite = Sprite::createWithSpriteFrameName("set_floor_v1.png");
messageboxSprite->setPosition(Point(480, 320));
layer->addChild(messageboxSprite, 1);
LabelTTF* labelContent = LabelTTF::create(Localization::getInstance()->getValueByKey("Loading_warning_need_update"), "Helvetica",32);
labelContent->setPosition(Point(480, 420));
layer->addChild(labelContent, 1);
ControlButton* btn = ControlButton::create(LabelTTF::create(Localization::getInstance()->getValueByKey("BUTTON_DONE"), "Helvetica", 32), Scale9Sprite::createWithSpriteFrameName("set_button2.png"));
btn->setPreferredSize(CCSize(191,70));
btn->setPosition(Point(480, 220));
btn->addTargetWithActionForControlEvents(this, cccontrol_selector(AssetsUpdateLayer::GoToAppPage), Control::EventType::TOUCH_UP_INSIDE);
layer->addChild(btn, 1);
}
示例2: compareCallback
void HelloWorld::compareCallback(CCObject* pSender)
{
CCScene* scene = CCScene::create();
CCLayer* layer = SingleTouch::create();
layer->setPosition(0,100);
layer->setScale(0.5);
scene->addChild(layer);
CCLayer* layer1 = SingleTouch1::create();
scene->addChild(layer1);
layer1->setPosition(200,100);
layer1->setScale(0.5);
CCDirector::sharedDirector()->replaceScene(scene);
}
示例3: newScrolling
void SelectCollection::newScrolling(MenuSpriteBatch* menu)
{
//Get the size of the screen we can see
CCSize visibleSize = Screen::getVisibleSize();
float scaled = Screen::getScaleFactor();
//Get the screen start of cordinates
CCPoint origin = Screen::getOrigin();
const float TOP_MARGIN = 140/scaled;
const float BOTTOM_MARGIN = 30/scaled;
float menu_left_padding = 0;
float min_height = 1000/scaled;
CCSize menu_size = menu->getContentSize();
float collection_height = menu_size.height;
if(collection_height < min_height)
{
collection_height = min_height;
menu_left_padding = (min_height - menu_size.height) / 2;
}
//Get the scroll area size
float scroll_view_width = visibleSize.width - TOP_MARGIN * 0.2;
float scroll_view_height = visibleSize.height-TOP_MARGIN - BOTTOM_MARGIN;
CCSize scroll_view_size(scroll_view_width, scroll_view_height);
//Create layer to fit all tiles
CCLayer *layer = CCLayer::create();
layer->setContentSize(CCSize(menu_size.width, menu_size.height));
//Create scroll view for this layer
CCScrollView* _collections_scroll_view = CCScrollView::create(
scroll_view_size,layer);
CCPoint collections_target_position(
origin.x + visibleSize.width/2 - scroll_view_size.width/2,
origin.y + BOTTOM_MARGIN);
float scale = scroll_view_width/menu_size.width;
layer->setScale(scale);
_collections_scroll_view->setPosition(collections_target_position);
_collections_scroll_view->setAnchorPoint(ccp(0.5, 0));
//CCRect eat_zone(origin.x,origin.y, visibleSize.width, _collections_scroll_view->getPositionY() + scroll_view_height);
CCRect eat_zone(origin.x,origin.y,
visibleSize.width,
visibleSize.height);
_collections_scroll_view->setTouchEatZone(eat_zone);
_collections_scroll_view->updateInset();
_collections_scroll_view->setDirection(kCCScrollViewDirectionVertical);
_collections_scroll_view->setContentOffset(_collections_scroll_view->minContainerOffset());
this->addChild(_collections_scroll_view);
//Add our tiles to scroll area
_collections_scroll_view->addChild(menu);
_collections_scroll_view->setMenu(menu->menu());
_collections_scroll_view->addHighPriorityTouchListener(_back_menu);
// this->addChild(menu);
menu->setAnchorPoint(ccp(0,0));
menu->setPosition(ccp(0,
0));
_pop_up_manager.addOnHideWindowAction([_collections_scroll_view](){
_collections_scroll_view->setTouchEnabled(true);
});
_pop_up_manager.addOnShowWindowAction([_collections_scroll_view](){
_collections_scroll_view->setTouchEnabled(false);
});
_pop_up_manager.addMenuToAutoDisable(menu->menu());
}