Пример #1
0
CCScene* CLoginLayer::scene()
{
    CCScene* scene = CCScene::create() ;
    CLoginLayer * layer = new CLoginLayer ;
    layer->init() ;
    scene->addChild(layer) ;
    layer->release() ;
    CCSize ptWinSize = CCDirector::sharedDirector()->getWinSize() ;
    scene->setContentSize(ptWinSize) ;
    CCSize ptLogicWinSize = CCDirector::sharedDirector()->getLogicWinSize() ;
    // scale layer ;
    float fScaleToHeight = (float)ptWinSize.height / (float)ptLogicWinSize.height ;
    float fScaledWidth = ptLogicWinSize.width * fScaleToHeight ;
    if ( fScaledWidth > ptWinSize.width )
    {
        float fScaleToWidth = (float)ptWinSize.width / (float)ptLogicWinSize.width ;
        layer->setScale(fScaleToWidth) ;
    }
    else
    {
        layer->setScale(fScaleToHeight) ;
    }
    layer->setPosition(ccp((ptWinSize.width - ptLogicWinSize.width ) * 0.5, (ptWinSize.height - ptLogicWinSize.height) *0.5 ));
    return scene ;
}