Ejemplo n.º 1
0
//开启幻灯片更新。
void UpdateLayer::switchUpdFrame(bool onoff)
{
    _updIsAutoPlaying = true;
    _updMaskLayer->setVisible(true);
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    ResourceManager* rm = ResourceManager::sharedInstance();
    rm->bindTexture("updatelayer/film1.plist", RES_TYPE_LAYER_UI, sg_updateLayer);
    rm->bindTexture("updatelayer/film2.plist", RES_TYPE_LAYER_UI, sg_updateLayer);
    rm->bindTexture("updatelayer/film3.plist", RES_TYPE_LAYER_UI, sg_updateLayer);
    rm->bindTexture("updatelayer/film4.plist", RES_TYPE_LAYER_UI, sg_updateLayer);
    
    //pos
    _updBasePos = ccp(0, winSize.height * 0.5 - 200);
    
    //frame
    _updFrame = CCLayerColor::create(ccc4(0,255,0,0), winSize.width, winSize.height);
    _updFrame->ignoreAnchorPointForPosition(false);
    _updFrame->setAnchorPoint(ccp(0.5, 0.5));
    _updFrame->setPosition(winSize * 0.5);
    
    //touchlayer
    _updTouchLayer = SGTouchLayer::create(winSize.width, 400, -128, ccc4(0,0,255,0));
    _updTouchLayer->setAnchorPoint(ccp(0,0));
    _updTouchLayer->setPosition(_updBasePos);
    _updTouchLayer->setControlMode(this, pf_began_selector(UpdateLayer::helloBegan), pf_moved_selector(UpdateLayer::helloMoved), pf_ended_selector(UpdateLayer::helloEnded), pf_cancelled_selector(UpdateLayer::helloCancelled));
    
    _updFrame->addChild(_updTouchLayer, 10);
    
    //star bkg
//    _updBkg = CCSprite::createWithSpriteFrameName("starSky.png");
//    _updBkg->setOpacity(150);
//    _updBkg->setScaleX(winSize.width / _updBkg->getContentSize().width);
//    _updBkg->setScaleY(winSize.height / _updBkg->getContentSize().height);
//    _updBkg->setPosition(winSize * 0.5);
//    _updFrame->addChild(_updBkg, 5);
    
    //posters' panel
    _updPostersPanel = CCLayerColor::create(ccc4(255,0,0,0), winSize.width, 200);
    _updPostersPanel->ignoreAnchorPointForPosition(false);
    _updPostersPanel->setAnchorPoint(ccp(0,0));
    _updPostersPanel->setPosition(_updBasePos);
    _updFrame->addChild(_updPostersPanel, 15);
    
    //posters
    _updCurPosterIndex = 0;
    CCSprite* spt;
    char sptName[20];
    float sptPosX = 0;
    CCSize sptSize;
    for (int k = 0; k < SLIDING_IMAGES_NUM; ++k)
    {
        sprintf(sptName, "poster%d.png", k);
        spt = CCSprite::createWithSpriteFrameName(sptName);
        spt->setAnchorPoint(ccp(0,0));
        sptSize = spt->getContentSize();
        //适配spt大小。
        float scale = 1;
        if (sptSize.width < winSize.width)
        {
            scale = winSize.width / sptSize.width;
            spt->setScale(scale);
        }
        float showWidth = sptSize.width * scale;
        
        spt->setPosition(ccp(sptPosX, 0));
        _updPostersPanel->addChild(spt, 10);
        //注意这里panel的移动方向和sptPosX是正好反过来的。
        _updPostersPanelPos[k] = ccp( -sptPosX - (showWidth - winSize.width) * 0.5, _updBasePos.y);
        sptPosX += showWidth;
        _updPosters[k] = spt;
    }
    
    //spots
    _updSpotsPanel = PointLayer::create(SLIDING_IMAGES_NUM, winSize.width, "anDian.png", "liangDian.png");
    _updSpotsPanel->setPosition(ccp(winSize.width * 0.5, _updBasePos.y - 50));
    _updFrame->addChild(_updSpotsPanel, 20);
    
    
    this->addChild(_updFrame, 100);
}
Ejemplo n.º 2
0
void SGWelComeLayer::initMsg()
{

    //MMDEBUG: BEGIN
#if SIMPLE_TEST

    ResourceManager* rm = ResourceManager::sharedInstance();
    rm->bindTexture("sgserverlistlayer/sgserverlistlayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity);
    rm->bindTexture("sgrewardlayer/sgrewardlayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity);
    rm->bindTexture("sgfirstactivitylayer/sgfirstactivitylayer.plist",RES_TYPE_LAYER_UI ,sg_luaactivity);
    rm->bindTexture("animationFile/short.plist",RES_TYPE_LAYER_UI ,sg_luaactivity);
    rm->bindTexture("sanguobigpic/barrack_bg.plist",RES_TYPE_LAYER_UI ,sg_luaactivity);
    
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    pEngine->executeScriptFile("qingming.lua"); //这里更换为自己的xxx.lua,lua文件请直接放在ipad文件夹下。
    return;
#endif
    //MMDEBUG: END
    
    //	CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
	ResourceManager::sharedInstance()->bindTexture("sgloginingbox/sgloginingbox.plist", RES_TYPE_LAYER_UI, sg_welComeLayer);
	ResourceManager::sharedInstance()->bindTexture("sgserverlistlayer/sgserverlistlayer.plist", RES_TYPE_LAYER_UI, sg_welComeLayer);
    CCUserDefault* ccud = CCUserDefault::sharedUserDefault();
    std::string localResVer = ccud->getStringForKey(SGUM_LOCAL_RES_VER_KEY);

    float fontSize = 8.0f;
    CCLabelTTF *version = CCLabelTTF::create(CCString::createWithFormat("V%s.%s", BUNDLE_VERSION,localResVer.c_str())->getCString(), FONT_PENGYOU, FONTSIZE(fontSize));
    version->setPosition(ccpAdd(SGLayout::getPoint(kBottomRight), ccp( -version->getContentSize().width * 0.6f, version->getContentSize().height * 0.5)));
    version->setColor(ccGREEN);
    this->addChild(version, 99999);
	
    //this->setTouchEnabled(true);   //removed by cgp

    CCPoint center = SGLayout::getPoint(kMiddleCenter);

    
    ResourceManager::sharedInstance()->bindTexture("sanguobigpic/logo.plist", RES_TYPE_LAYER_UI, sg_welComeLayer);
    ResourceManager::sharedInstance()->bindTexture("sanguobigpic/login_ip5.plist", RES_TYPE_LAYER_UI, sg_welComeLayer);
    
    //removed by cgp for welcomelayer
//    logo = CCSprite::createWithSpriteFrameName("logo.png");
//    this->addChild(logo,10);

    CCSprite *bg = CCSprite::createWithSpriteFrameName("login_ip5.png");
    bg->setScaleY(CCDirector::sharedDirector()->getWinSize().height / bg->getContentSize().height);
    bg->setScaleX(CCDirector::sharedDirector()->getWinSize().width / bg->getContentSize().width);
    this->addChild(bg,-1);
    bg->setPosition(center);
    
//logo->setPosition(ccpAdd(center, ccp(0, bg->getContentSize().height * 0.11)));
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    //m_blackColor = CCLayerColor::create(ccc4(0, 0, 0, 0), winSize.width, winSize.height);
    //m_blackColor = CCLayerColor::create(ccc4(0, 0, 0, 180), winSize.width, winSize.height);
   // m_blackColor->setTouchEnabled(false);
   // m_blackColor->setPosition(0,0);
    
//    SGButton *login_start = SGButton::createFromLocal("login_start.png", "", this, NULL, CCPointZero, FONT_BOXINFO, ccRED, 26, false, true);
//    this->addChild(login_start , 21);
//    login_start->setPosition(ccpAdd(SGLayout::getPoint(kBottomCenter), ccp(0, screenheight * 0.2)));
//    login_start->setTag(1);
//    login_start->runAction(CCRepeatForever::create(CCBlink::create(1.5, 1)));
//    EFFECT_PLAY(MUSIC_BTN);

    CCUserDefault::sharedUserDefault()->setBoolForKey("pvp_tran",false);//每次登入时取消pvp登入状态
    
     SGStaticDataManager::shareStatic()->getOfficerById(1001);    //added by cgp for battle of officer table
     loginstart();
    
}