当前位置: 首页>>代码示例>>C++>>正文


C++ Coin::setScale方法代码示例

本文整理汇总了C++中Coin::setScale方法的典型用法代码示例。如果您正苦于以下问题:C++ Coin::setScale方法的具体用法?C++ Coin::setScale怎么用?C++ Coin::setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Coin的用法示例。


在下文中一共展示了Coin::setScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

// on "init" you need to initialize your instance
bool Interface::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    
    /////////////////////////////
    // 3. add your codes below...
    
    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("0", "Arial", TITLE_FONT_SIZE);
    
    pLabel->setAnchorPoint(ccp(0.0f, 0.5f));
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));
    
    pLabel->setTag(10);
    
    // add the label as a child to this layer
    this->addChild(pLabel, 1);
    
    Coin* coin = Coin::create();
    coin->setAnchorPoint(ccp(0.5f, 0.5f));
    coin->setScale(2.0f);
    coin->setPosition(ccp((origin.x + visibleSize.width/2) - coin->getContentSize().width,
                              origin.y + visibleSize.height - pLabel->getContentSize().height));
    
    // add the sprite as a child to this layer
    this->addChild(coin, 2);
    
    
    CCLabelTTF* parachuteLabel = CCLabelTTF::create("10 sec", "Arial", TITLE_FONT_SIZE);
    
    parachuteLabel->setAnchorPoint(ccp(0.0f, 0.5f));
    
#ifdef CC_TARGET_OS_MAC
    // position the label on the center of the screen
    parachuteLabel->setPosition(ccp(50.0f,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));
#endif
    
#ifdef OUYA_BUILD
    // position the label on the center of the screen
    parachuteLabel->setPosition(ccp(60.0f,
                                    origin.y + visibleSize.height - pLabel->getContentSize().height));
#endif
    
    parachuteLabel->setTag(20);
    
    // add the label as a child to this layer
    this->addChild(parachuteLabel, 1);
    
    
    Parachute* parachute = Parachute::create();
    parachute->setAnchorPoint(ccp(0.5f, 0.5f));
    parachute->setScale(1.0f);
#ifdef CC_TARGET_OS_MAC
    parachute->setPosition(ccp((50.0f) - parachute->getContentSize().width / 2.0f,
                               origin.y + visibleSize.height - pLabel->getContentSize().height));
#endif
#ifdef OUYA_BUILD
    parachute->setPosition(ccp((60.0f) - parachute->getContentSize().width / 2.0f,
                          origin.y + visibleSize.height - pLabel->getContentSize().height));
#endif
    // add the sprite as a child to this layer
    this->addChild(parachute, 3);
    
    return true;
}
开发者ID:OneGameAMonth,项目名称:Cocos2d-x,代码行数:80,代码来源:Interface.cpp


注:本文中的Coin::setScale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。