本文整理汇总了C++中Box2DView::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Box2DView::setScale方法的具体用法?C++ Box2DView::setScale怎么用?C++ Box2DView::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2DView
的用法示例。
在下文中一共展示了Box2DView::setScale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWithEntryID
bool MenuLayer::initWithEntryID(int entryId)
{
CGSize s = CCDirector::sharedDirector()->getWinSize();
m_entryID = entryId;
setIsTouchEnabled( true );
Box2DView* view = Box2DView::viewWithEntryID( entryId );
addChild(view, 0, kTagBox2DNode);
view->setScale(15);
view->setAnchorPoint( ccp(0,0) );
view->setPosition( ccp(s.width/2, s.height/3) );
CCLabelTTF* label = CCLabelTTF::labelWithString(view->title().c_str(), "Arial", 28);
addChild(label, 1);
label->setPosition( ccp(s.width/2, s.height-50) );
CCMenuItemImage *item1 = CCMenuItemImage::itemFromNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) );
CCMenuItemImage *item2 = CCMenuItemImage::itemFromNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) );
CCMenuItemImage *item3 = CCMenuItemImage::itemFromNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) );
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
menu->setPosition( CGPointZero );
item1->setPosition( ccp( s.width/2 - 100,30) );
item2->setPosition( ccp( s.width/2, 30) );
item3->setPosition( ccp( s.width/2 + 100,30) );
addChild(menu, 1);
return true;
}
示例2: addChild
bool Box2dTestBed::initWithEntryID(int entryId)
{
if (!TestCase::init())
{
return false;
}
auto director = Director::getInstance();
Vec2 visibleOrigin = director->getVisibleOrigin();
Size visibleSize = director->getVisibleSize();
m_entryID = entryId;
Box2DView* view = Box2DView::viewWithEntryID( entryId );
addChild(view, 0, kTagBox2DNode);
view->setScale(15);
view->setAnchorPoint( Vec2(0,0) );
view->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3);
auto label = Label::createWithTTF(view->title().c_str(), "fonts/arial.ttf", 28);
addChild(label, 1);
label->setPosition(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50);
// Adds touch event listener
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(Box2dTestBed::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(Box2dTestBed::onTouchMoved, this);
_eventDispatcher->addEventListenerWithFixedPriority(listener, 1);
_touchListener = listener;
return true;
}
示例3: initWithEntryID
bool MenuLayer::initWithEntryID(int entryId)
{
auto director = Director::getInstance();
Point visibleOrigin = director->getVisibleOrigin();
Size visibleSize = director->getVisibleSize();
m_entryID = entryId;
setTouchEnabled( true );
setTouchMode(Touch::DispatchMode::ONE_BY_ONE);
Box2DView* view = Box2DView::viewWithEntryID( entryId );
addChild(view, 0, kTagBox2DNode);
view->setScale(15);
view->setAnchorPoint( Point(0,0) );
view->setPosition( Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3) );
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE)
// auto label = LabelBMFont::create(view->title().c_str(), "fonts/arial16.fnt");
//#else
auto label = LabelTTF::create(view->title().c_str(), "Arial", 28);
//#endif
addChild(label, 1);
label->setPosition( Point(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) );
auto item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(MenuLayer::backCallback, this) );
auto item2 = MenuItemImage::create("Images/r1.png","Images/r2.png", CC_CALLBACK_1( MenuLayer::restartCallback, this) );
auto item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(MenuLayer::nextCallback, this) );
auto menu = Menu::create(item1, item2, item3, NULL);
menu->setPosition( Point::ZERO );
item1->setPosition(Point(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(Point(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
// Removes touch event listener
EventDispatcher::getInstance()->removeEventListener(_touchListener);
// Adds touch event listener
auto listener = EventListenerTouch::create(Touch::DispatchMode::ONE_BY_ONE);
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(MenuLayer::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(MenuLayer::onTouchMoved, this);
EventDispatcher::getInstance()->addEventListenerWithFixedPriority(listener, 1);
_touchListener = listener;
return true;
}
示例4: initWithEntryID
bool MenuLayer::initWithEntryID(int entryId)
{
auto director = Director::getInstance();
Vec2 visibleOrigin = director->getVisibleOrigin();
Size visibleSize = director->getVisibleSize();
m_entryID = entryId;
Box2DView* view = Box2DView::viewWithEntryID( entryId );
addChild(view, 0, kTagBox2DNode);
view->setScale(15);
view->setAnchorPoint( Vec2(0,0) );
view->setPosition( Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height/3) );
auto label = Label::createWithTTF(view->title().c_str(), "fonts/arial.ttf", 28);
addChild(label, 1);
label->setPosition( Vec2(visibleOrigin.x+visibleSize.width/2, visibleOrigin.y+visibleSize.height-50) );
auto item1 = MenuItemImage::create("Images/b1.png", "Images/b2.png", CC_CALLBACK_1(MenuLayer::backCallback, this) );
auto item2 = MenuItemImage::create("Images/r1.png","Images/r2.png", CC_CALLBACK_1( MenuLayer::restartCallback, this) );
auto item3 = MenuItemImage::create("Images/f1.png", "Images/f2.png", CC_CALLBACK_1(MenuLayer::nextCallback, this) );
auto menu = Menu::create(item1, item2, item3, nullptr);
menu->setPosition( Vec2::ZERO );
item1->setPosition(Vec2(VisibleRect::center().x - item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
item2->setPosition(Vec2(VisibleRect::center().x, VisibleRect::bottom().y+item2->getContentSize().height/2));
item3->setPosition(Vec2(VisibleRect::center().x + item2->getContentSize().width*2, VisibleRect::bottom().y+item2->getContentSize().height/2));
addChild(menu, 1);
// Adds touch event listener
auto listener = EventListenerTouchOneByOne::create();
listener->setSwallowTouches(true);
listener->onTouchBegan = CC_CALLBACK_2(MenuLayer::onTouchBegan, this);
listener->onTouchMoved = CC_CALLBACK_2(MenuLayer::onTouchMoved, this);
_eventDispatcher->addEventListenerWithFixedPriority(listener, 1);
_touchListener = listener;
return true;
}