void ClassicScene::initBg() { CCSprite *bg = SPRITE(images/stage_classic/stage_bg_RETINA.png); bg->setPosition(VisibleRect::center()); addChild(bg); CCSprite *bgWood = SPRITE(images/stage_classic/stage_tree_RETINA.png); CCSprite *floor = SPRITE(images/stage_classic/stage_tree_grass_RETINA.png); floor->setPosition(ccp(VisibleRect::center().x,44)); bgWood->setPosition(ccp(VisibleRect::center().x,-400)); CCActionInterval *moveAct = CCMoveTo::create(0.6f,ccp(VisibleRect::center().x,400)); CCCallFunc *showBirdLayerHandler = CCCallFunc::create(this,callfunc_selector(ClassicScene::showBirdLayer)); bgWood->runAction(CCSequence::create(moveAct,showBirdLayerHandler,NULL)); addChild(bgWood); birdLayer = BirdLayer::create(); birdLayer->setPosition(ccp(VisibleRect::center().x,-400)); addChild(birdLayer); addChild(floor); BaseSprite *pauseBtn = BaseSprite::createFromFile("images/stage_classic/stage_dimm2_RETINA.png","sounds/SFX/pausebuttonclick.mp3"); pauseBtn->setPosition(ccp(50,VisibleRect::top().y-50)); pauseBtn->setOpacity(0); pauseBtn->setBeganTarget(this,menu_selector(ClassicScene::pauseGame)); addChild(pauseBtn); }
bool ChatLayer::init() { bool bRet = false; do { CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) ); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //board CCSprite* board = CCSprite::create("juqing_duihuakuang.png"); addChild(board, 2, TAG_Board); board->setAnchorPoint(ccp(0.5, 0)); board->setPosition(ccp(winSize.width/2, 0)); board->setOpacity(0); //next img BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png"); board->addChild(nextImg, 0, Tag_ImgNext); nextImg->setPosition(ccp(597,37)); nextImg->setOpacity(0); nextImg->runAction(CCSequence::create( CCFadeIn::create(0.15f), CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1), NULL)); //npc string npcFileName = getFileByName(m_chatContext.at(0).name).second; //////////////////////////////////////////// if(npcFileName.empty()) { CCLog("Error: %s [can't found npc imgine]", __FUNCTION__); npcFileName = "juqing_duihua_NPC_shenmiren.png"; } //////////////////////////////////////////// CCSprite* actorA = CCSprite::create(npcFileName.c_str()); addChild(actorA, 1, TAG_ActorA); actorA->setAnchorPoint(ccp(0,0)); actorA->setPosition(ccp(0, board->getContentSize().height-14)); actorA->setOpacity(0); //actor //yemanren cike fashi string actorFileName = getFileByName("zhujue").second; CCSprite* actorB = CCSprite::create(actorFileName.c_str()); addChild(actorB, 1, TAG_ActorB); actorB->setAnchorPoint(ccp(1,0)); actorB->setPosition(ccp(winSize.width, board->getContentSize().height-14)); // actorB->setScale(0.9); actorB->setOpacity(0); //label name CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24); addChild(namelabel, 5, Tag_Label_Name); namelabel->setAnchorPoint(ccp(0, 0.5)); namelabel->setPosition(ccp(20, board->getContentSize().height-42)); namelabel->setColor(fonColor_PuTong); namelabel->setOpacity(0); //label content CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(610, 0), kCCTextAlignmentLeft); addChild(label, 5, TAG_label); label->setAnchorPoint(ccp(0,1)); label->setColor(fonColor_FaGuang); label->setPosition(ccp(20, board->getContentSize().height-76)); label->setOpacity(0); ////////////start chat if(m_chatContext.at(0).name == "zhujue") actorB->runAction(CCFadeIn::create(0.1f)); else actorA->runAction(CCFadeIn::create(0.1f)); board->runAction(CCFadeIn::create(0.1f)); label->runAction(CCFadeIn::create(0.1f)); namelabel->runAction(CCFadeIn::create(0.1f)); nextImg->runAction(CCFadeIn::create(0.15f)); scheduleOnce(schedule_selector(ChatLayer::showChatContext), 0.05f); { mTimeEnd = false; mLabelFadeInEnd = false; ++m_index; } bRet = true; }while(0); return bRet; }
bool ZhuShouChatLayer::init() { bool bRet = false; do { CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) ); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //board CCSprite* board = CCSprite::create("juqing_duihuakuang.png"); addChild(board, 2, TAG_Board); board->setAnchorPoint(ccp(0.5, 0)); board->setPosition(ccp(winSize.width/2, 0)); board->setOpacity(0); board->setScaleY(0.7f); //next img BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png"); board->addChild(nextImg, 0, Tag_ImgNext); nextImg->setPosition(ccp(597,37)); nextImg->setOpacity(0); nextImg->runAction(CCSequence::create( CCFadeIn::create(0.15f), CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1), NULL)); //npc string npcFileName = getFileByName(getPinyinName(m_nZhuaShouId)).second; //////////////////////////////////////////// if(npcFileName.empty()) { CCLog("Error: %s [can't found npc imgine]", __FUNCTION__); npcFileName = "juqing_duihua_NPC_shenmiren.png"; } //////////////////////////////////////////// int x_side = 20; CCSprite* actorA = CCSprite::create(npcFileName.c_str()); addChild(actorA, 3, TAG_ActorA); actorA->setAnchorPoint(ccp(0,0)); actorA->setPosition(ccp(x_side,x_side)); actorA->setOpacity(0); int side = 10; //label name CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24); addChild(namelabel, 5, Tag_Label_Name); namelabel->setAnchorPoint(ccp(0, 0.5)); namelabel->setPosition(ccp(20, board->getContentSize().height-42)); namelabel->setColor(fonColor_PuTong); namelabel->setOpacity(0); //label content //CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(board->getContentSize().width - actorA->getContentSize().width - side, 0), kCCTextAlignmentLeft); m_nTextWidth = board->getContentSize().width - actorA->getContentSize().width - side; NetLabelTTF* label = NetLabelTTF::create("", fontStr_kaiti, 24); addChild(label, 5, TAG_label); label->setHorizontalAlignment(kCCTextAlignmentLeft); label->setAnchorPoint(ccp(0,1)); label->setColor(fonColor_FaGuang); label->setPosition(ccp(actorA->getContentSize().width + side, board->getContentSize().height-145)); label->setOpacity(0); actorA->runAction(CCFadeIn::create(0.0f)); board->runAction(CCFadeIn::create(0.0f)); label->runAction(CCFadeIn::create(0.0f)); namelabel->runAction(CCFadeIn::create(0.0f)); nextImg->runAction(CCFadeIn::create(0.0f)); scheduleOnce(schedule_selector(ZhuShouChatLayer::showChatContext), 0.05f); { mTimeEnd = false; mLabelFadeInEnd = false; ++m_index; } bRet = true; } while(0); return bRet; }