Beispiel #1
0
void StoryWorld::makeAChoice(CCObject *sender) {
    int choice = ((CCNode *)sender)->getTag();
    if (current == '3') {
        switch (choice) {
            case fChoice: {
                // 显示宣传单一
                cout << "xuanchuan " << endl;
                removeChildByTag(2);
                removeChildByTag(3);
                CCSprite *blackBG = CCSprite::create(BLACK_IMG_PATH);
                blackBG->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width/2, CCDirector::sharedDirector()->getVisibleSize().height/2));
                blackBG->setScale(1);
                blackBG->setTag(21);
                addChild(blackBG, 2);
                // TODO
                CCLabelTTF *xuanchuan = CCLabelTTF::create();
                xuanchuan->setPosition(ccp(0, 40));
                xuanchuan->setHorizontalAlignment(kCCTextAlignmentLeft);
                xuanchuan->setAnchorPoint(CCPointZero);
                xuanchuan->setDimensions(CCSizeMake(1100, 0));
                xuanchuan->setTag(22);
                addChild(xuanchuan, 3);
                
                // 关闭按钮
                CCMenuItemImage *start = CCMenuItemImage::create(LEAFLET_IMG_PATH,
                                                                 LEAFLET_IMG_PATH,
                                                                 this,
                                                                 menu_selector(StoryWorld::menuLeafletsCloseCallback));
                
                start->setPosition(ccp(CCDirector::sharedDirector()->getVisibleSize().width-40, CCDirector::sharedDirector()->getVisibleSize().height-40));
                
                //菜单
                CCMenu* pMenu = CCMenu::create(start, NULL);
                pMenu->setPosition(CCPointZero);
                pMenu->setTag(23);
                addChild(pMenu, 4);
                
                
            }
                return;
            case sChoice:
			default:{
				current+=1;
				CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480, 320, kResolutionExactFit);
				CCDirector::sharedDirector()->popScene();
            }
                return;
        }
    }
    char fileName[8] = "Fin ";
    
    switch (choice) {
        case fChoice:
            fileName[3]='1';
            break;
        case sChoice:
            fileName[3]='2';
            break;
        case tChoice:
            fileName[3]='3';
            break;
        default:
            break;
    }
    reader.ChangeFile(cocos2d::CCFileUtils::sharedFileUtils()->fullPathForFilename(fileName));
    
    removeChildByTag(2);
    removeChildByTag(3);
    setTouchEnabled(true);
    
    avgGame();
}
Beispiel #2
0
bool StoryWorld::init() {
  if ( !CCLayer::init() ) {
    return false;
  }
  char theName[10][11]={"","穆婧:", "子轩:", "少杰:", "建国", "路人A:", "路人B:", "路人C:", "老爷爷:", "江姐:"};
  char play[20] = SCRIPT_PATH;
  current=sGlobal->mapState->storyCnt+'0';
  play[SCRIPT_PATH_LEN] = current;
  reader.ReadFileWithFullPath(CCFileUtils::sharedFileUtils()->fullPathForFilename(play));
  this->setTouchEnabled(true);
  CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
  CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
  
  char bg_name[30] = "" ;
  char bg_num[4]="";
  sprintf(bg_num, "%c00", current);
  sprintf(bg_name, BGNAME_IMG_PATH, bg_num);
  CCSprite *pBackground = CCSprite::createWithTexture(GET_TEXTURE(bg_name));
  //CCSprite* pBackground = CCSprite::create(bg_name);
  pBackground->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
  pBackground->setScale(1);
  pBackground->setTag(108);
  addChild(pBackground, 0);
  
  CCSprite* dialogBox = CCSprite::create(DUIHUAKUANG_IMG_PATH);
  dialogBox->setPosition(ccp(visibleSize.width/2, dialogBox->getContentSize().height/2));
  dialogBox->setOpacity(220);
  addChild(dialogBox,1);
  
  CCLabelTTF* pName = CCLabelTTF::create(theName[0], "Heiti SC", 40);
  pName->setTag(101);
  pName->setPosition(ccp(pName->getContentSize().width/2, dialogBox->getContentSize().height - 2 * pName->getContentSize().height));
  pName->setAnchorPoint(CCPointZero);
  addChild(pName, 1);
  
  
  CCLabelTTF* pLabel = CCLabelTTF::create("Click to Start", "Heiti SC", 40);
  pLabel->setTag(100);
  pLabel->setPosition(ccp(40, origin.y + dialogBox->getContentSize().height - 3.4 * pLabel->getContentSize().height));
  pLabel->setAnchorPoint(CCPointZero);
  pLabel->setDimensions(CCSizeMake(1100, 0));
  pLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
  addChild(pLabel, 1);
  
  
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(PLIST_IMG_PATH);
	CCSpriteBatchNode *spriteBatch = CCSpriteBatchNode::createWithTexture(GET_TEXTURE(VDRAWING_IMG_PATH));
  spriteBatch->setTag(102);
  addChild(spriteBatch, 0);
  spriteBatch->setPosition(CCPointZero);
  
  CCSprite *leftSprite=CCSprite::createWithSpriteFrameName("me_1.png");
  leftSprite->setScale(0.8);
  leftSprite->setPosition(ccp(leftSprite->getContentSize().width*0.6, leftSprite->getContentSize().height/2 *0.8));
  leftSprite->setTag(1);
  leftSprite->setOpacity(0);
  spriteBatch->addChild(leftSprite, 0);
  
  CCSprite *rightSprite=CCSprite::createWithSpriteFrameName("blank.png");
  //rightSprite->setScale(0.8);
  rightSprite->setPosition(ccp(800, 130));
  rightSprite->setTag(2);
  rightSprite->setOpacity(0);
  spriteBatch->addChild(rightSprite, 0);
  
  avgGame();
  return true;
}
Beispiel #3
0
// 初始化顶部bar
void MessageView::initTopBar(CCSize winSize)
{
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    // topBarNode 背景
    CCSprite* topBarBg = CCSprite::create("bg_nav_top.png") ;
    topBarBg->setAnchorPoint(ccp(0.5, 0)) ;
    topBarBg->setPosition(ccp(winSize.width/2, 0)) ;

    const float topBar_height = topBarBg->getContentSize().height ;



    // 顶部条信息 //////////////////////////////////////////////////////////////////////////////////////
    this->topBarNode = CCNode::create() ;
    this->topBarNode->setContentSize(CCSizeMake(winSize.width, topBar_height)) ;
    this->topBarNode->setAnchorPoint(ccp(0, 0)) ;
    this->topBarNode->setPosition(ccp(0, winSize.height - topBar_height)) ;
    this->addChild(this->topBarNode, 0, 1) ;

    // 将topBarNode背景加入到topBarNode
    this->topBarNode->addChild(topBarBg, 0 ) ;


    ///////////////////////////// 左侧布局 //////////////////////////
    CCNode* leftNode = CCNode::create() ;
    leftNode->setContentSize(CCSizeMake(300, topBar_height)) ;
    leftNode->setAnchorPoint(ccp(0, 0.5)) ;
    leftNode->setPosition(ccp(30, topBar_height/2)) ;
    this->topBarNode->addChild(leftNode, 1) ;

    // 头像
    CCSprite* headPortraitSprite = CCSprite::create("user/head_default_f2.png") ;
    headPortraitSprite->setAnchorPoint(ccp(0, 0)) ;
    headPortraitSprite->setPosition(ccp(0, 10)) ;
    headPortraitSprite->setScale(0.8) ;
    leftNode->addChild(headPortraitSprite) ;

    // 昵称
    CCLabelTTF* nikeNameLabel = CCLabelTTF::create("昵称:我是主角", "font01.ttf", 22.0f) ;
    // nikeNameLabel->setColor(ccc3(191, 173, 111)) ;
    nikeNameLabel->setAnchorPoint(ccp(0, 0)) ;
    nikeNameLabel->setPosition(ccp(70, topBar_height/2+2)) ;
    nikeNameLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
    nikeNameLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
    leftNode->addChild(nikeNameLabel) ;

    // 金币
    CCLabelTTF* goldCoinLabel = CCLabelTTF::create("金币:10000", "font01.ttf", 22.0f) ;
    goldCoinLabel->setAnchorPoint(ccp(0, 1)) ;
    goldCoinLabel->setPosition(ccp(70, topBar_height/2)) ;
    goldCoinLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
    goldCoinLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
    leftNode->addChild(goldCoinLabel) ;


    // 信息
    CCSprite* titleMsg = CCSprite::create("icon_title_message.png") ;
    titleMsg->setAnchorPoint(ccp(0.5, 0.5)) ;
    titleMsg->setPosition(ccp(winSize.width/2, topBar_height/2)) ;
    this->topBarNode->addChild(titleMsg, 1) ;

    // 分割线
    CCSprite* spliteLineLeft = CCSprite::create("icon_top_nav_splite.png") ;
    spliteLineLeft->setAnchorPoint(ccp(0, 1)) ;
    spliteLineLeft->setPosition(ccp(winSize.width/3+10, topBar_height)) ;
    this->topBarNode->addChild(spliteLineLeft, 1) ;


    // 分割线
    CCSprite* spliteLineRight = CCSprite::create("icon_top_nav_splite.png") ;
    spliteLineRight->setAnchorPoint(ccp(0, 1)) ;
    spliteLineRight->setPosition(ccp(winSize.width*2/3-20, topBar_height)) ;
    this->topBarNode->addChild(spliteLineRight, 1) ;


    /////////////////////////////////////////////////////////////////////////////////////////////////
    /****************************** 菜单选项 ********************************************************/
    // 右侧menu
    const float right_width = 200 ;
    const float item_width = 55 ;


    // 礼物
    CCMenuItemImage* menuGifts = CCMenuItemImage::create("menu_gifts_n.png", "menu_gifts_s.png", this,
                                 menu_selector(MessageView::menuGiftsClickCallback)) ;
    // menuBack->setContentSize(CCSizeMake(67, 68)) ;
    menuGifts->setAnchorPoint(ccp(0, 0.5)) ;
    menuGifts->setPosition(ccp(0, topBar_height/2)) ;
    //menuGifts->setPosition(ccp(right_width-2*item_width, topBar_height/2)) ;
    //rightMenu->addChild(menuGifts) ;

    // 返回大厅
    CCMenuItemImage* menuBack = CCMenuItemImage::create("menu_back_n.png", "menu_back_s.png", this,
                                menu_selector(MessageView::menuBackClickCallback)) ;
    menuBack->setAnchorPoint(ccp(0, 0.5)) ;
    menuBack->setPosition(ccp(2*(item_width+10), topBar_height/2)) ;
    //menuBack->setPosition(ccp(right_width, topBar_height/2)) ;
    //rightMenu->addChild(menuBack) ;

    // 设置
    CCMenuItemImage* menuSetting = CCMenuItemImage::create("menu_setting_n.png", "menu_setting_s.png", this,
                                   menu_selector(MessageView::menuSettingClickCallback)) ;
    // menuBack->setContentSize(CCSizeMake(67, 68)) ;

    menuSetting->setAnchorPoint(ccp(0, 0.5)) ;
    menuSetting->setPosition(ccp(item_width+10, topBar_height/2)) ;
    //menuSetting->setPosition(ccp(right_width-item_width, topBar_height/2)) ;


    //rightMenu->addChild(menuSetting) ;
    CCMenu* rightMenu = CCMenu::create(menuGifts, menuBack, menuSetting, NULL) ;
    rightMenu->setContentSize(CCSizeMake(winSize.width/4, topBar_height)) ;
    rightMenu->setAnchorPoint(ccp(0, 0)) ;
    rightMenu->setPosition(ccp(winSize.width*3/4-10, 0)) ;
    this->topBarNode->addChild(rightMenu, 1) ;
}