//初始化方法
bool GameOver::init() {
    Layer::init();
    setColor(Color3B::WHITE);
    
    auto size = Director::getInstance()->getVisibleSize();
    //添加一个label 显示结束语
    auto lable = Label::create();
    lable->setString("Game Over!");
    lable->setSystemFontSize(80);
    lable->setTextColor(Color4B::WHITE);
    lable->setPosition(size/2);
    addChild(lable);
    
    //添加另一个label 作为重新开始按钮
    auto label_2 = Label::create();
    label_2->setString("不服,再来");
    label_2->setTextColor(Color4B::WHITE);
    label_2->setSystemFontSize(30);
    label_2->setPosition(size.width/2 , 100);
    addChild(label_2);
    
    //绑定触摸方法
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = [label_2](Touch *touch, Event *event){
        if (label_2->getBoundingBox().containsPoint(touch->getLocation())) {
            auto game = HelloWorld::createScene();
            Director::getInstance()->replaceScene(game);
        }
        return false;
    };
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
    
    return true;
}
Exemple #2
0
bool EndLine::initWithContext(HelloWorld *context){
    this->context = context;
    visibleSize = Director::getInstance()->getVisibleSize();
    Block::initWithArgs(Color3B::GREEN, visibleSize, "游戏结束", 50, Color4B::BLACK);
    
    auto label = Label::create();
    label->setString("再玩一次");
    label->setSystemFontSize(50);
    label->setPosition(visibleSize.width/2, label->getContentSize().height/2+50);
    label->setTextColor(Color4B::RED);
    addChild(label);
    
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = [this](Touch* t,Event * e){
        
        if (e->getCurrentTarget()->getBoundingBox().containsPoint(t->getLocation()-e->getCurrentTarget()->getParent()->getPosition())) {
            
            this->context->init();
        }
        return false;
    };
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, label);
    
    return true;
}
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
    _placeHolder = placeholder;

    do
    {
        // If fontName is ttf file and it corrected, use TTFConfig
        if (FileUtils::getInstance()->isFileExist(fontName))
        {
            TTFConfig ttfConfig(fontName, fontSize, GlyphCollection::DYNAMIC);
            if (setTTFConfig(ttfConfig))
            {
                break;
            }
        }

        setSystemFontName(fontName);
        setSystemFontSize(fontSize);

    } while (false);


    Label::setTextColor(_colorSpaceHolder);
    Label::setString(_placeHolder);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
    // On desktop default enable cursor
    if (_currentLabelType == LabelType::TTF)
    {
        setCursorEnabled(true);
    }
#endif

    return true;
}
Label * GameOver::createButton(std::string text, float fontSize){
    auto l = Label::create();
    l->setString(text);
    l->setColor(Color3B::BLACK);
    l->setSystemFontSize(fontSize);
    return l;
}
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const std::string& fontName, float fontSize)
{
    _placeHolder = std::string(placeholder);
    setSystemFontName(fontName);
    setSystemFontSize(fontSize);
    Label::setTextColor(_colorSpaceHolder);
    Label::setString(_placeHolder);

    return true;
}
void FightLayer::combatEnd(){
    
    auto endLayer = LayerColor::create(Color4B(0,0,0,192),VisibleRect::rect().size.width, VisibleRect::rect().size.height);
    endLayer->setPosition(0,0);
    addChild(endLayer);
    
    auto lblExperience = Label::create();
    lblExperience->setString("Experience:" + Utile::convertIntToString(_endVec.at(0)->getExperience()));
    lblExperience->setSystemFontSize(66);
    lblExperience->setPosition(VisibleRect::center()+Point(0,100));
    
    auto lblisWin = Label::create();
    lblisWin->setString(_endVec.at(0)->getResult()?"You Win !": "You Lost!");
    lblisWin->setSystemFontSize(66);
    lblisWin->setPosition(VisibleRect::center()+Point(0,-100));
    
    endLayer->addChild(lblExperience);
    endLayer->addChild(lblisWin);
}
void GameOver::setScoreInfo(const std::string &scoreInfo) {
    auto size = Director::getInstance()->getVisibleSize();
    
    //添加一个label 显示结束语
    auto lable = Label::create();
    lable->setString(scoreInfo);
    lable->setSystemFontSize(30);
    lable->setTextColor(Color4B::WHITE);
    lable->setPosition(size.width /2, size.height /2 - 100);
    addChild(lable);
}
bool TextFieldTTF::initWithPlaceHolder(const std::string& placeholder, const Size& dimensions, TextHAlignment alignment, const std::string& fontName, float fontSize)
{
    _placeHolder = placeholder;
    setDimensions(dimensions.width,dimensions.height);
    setSystemFontName(fontName);
    setSystemFontSize(fontSize);
    setAlignment(alignment,TextVAlignment::CENTER);
    Label::setTextColor(_colorSpaceHolder);
    Label::setString(_placeHolder);

    return true;
}
// on "init" you need to initialize your instance
bool StartUp::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !LayerColor::initWithColor(Color4B(255, 255, 255, 255)) )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    
    
    addBtns();
    addBtnListeners();
    
    //add logo
    auto logo = Sprite::create("logo.png");
    addChild(logo);
    logo->setPosition(visibleSize.width/2,20);
    logo->setAnchorPoint(Vec2(0.5, 0));
    
    //add title
    auto titleLabel = Label::create();
    titleLabel->setSystemFontSize(40);
    titleLabel->setString("一个都不能死");
    titleLabel->setColor(Color3B::BLACK);
    titleLabel->setPosition(visibleSize.width/2, visibleSize.height - titleLabel->getContentSize().height/2 -20);
    addChild(titleLabel);
    
    //add open source url
    auto osu = Label::create();
    osu->setSystemFontSize(12);
    osu->setString("开源地址:https://github.com/plter/NoOneDies\n极客学院:http://jikexueyuan.com");
    osu->setColor(Color3B::BLACK);
    osu->setPosition(visibleSize.width/2, titleLabel->getPositionY()-titleLabel->getContentSize().height/2-20);
    addChild(osu);
    
    return true;
}
bool GameOver::initWithCurrentHeroCountAndScore(int currentHeroCount, double score){
    LayerColor::initWithColor(Color4B(255, 255, 255, 255));
    
    _currentHeroCount = currentHeroCount;
    _score = score;
    
    auto label = Label::create();
    label->setString("游戏结束");
    label->setColor(Color3B(0, 0, 0));
    label->setSystemFontSize(40);
    addChild(label);
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    
    label->setPosition(visibleSize.width/2, visibleSize.height-label->getContentSize().height/2-80);
    
    //add replay btn
    btnReplay = createButton("再来一次", 32);
    btnReplay->setPosition(visibleSize.width/2, label->getPositionY()-label->getContentSize().height/2-150);
    addChild(btnReplay);
    //add gohome btn
    btnGoHome = createButton("回主页", 32);
    btnGoHome->setPosition(visibleSize.width/2, btnReplay->getPositionY()-btnReplay->getContentSize().height/2-50);
    addChild(btnGoHome);
    
    //add logo
    auto logo = Sprite::create("logo.png");
    addChild(logo);
    logo->setPosition(visibleSize.width/2,20);
    logo->setAnchorPoint(Vec2(0.5, 0));
    
    touchListener = EventListenerTouchOneByOne::create();
    touchListener->onTouchBegan = [this](Touch *t,Event *e){
        if (this->btnGoHome->getBoundingBox().containsPoint(t->getLocation())) {
            Director::getInstance()->getEventDispatcher()->removeEventListener(touchListener);
            Director::getInstance()->replaceScene(StartUp::createScene());
        }else if (this->btnReplay->getBoundingBox().containsPoint(t->getLocation())){
            Director::getInstance()->getEventDispatcher()->removeEventListener(touchListener);
            Director::getInstance()->replaceScene(Game::createScene(this->_currentHeroCount));
        }
        
        return false;
    };
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);
    
    return true;
}
Exemple #11
0
bool Areas::initWithArgs(Color3B color, Size size, std::string lable, float fontSize, Color4B textColor,int tag){
	Sprite::init();
	
	setAnchorPoint(Point::ZERO);
	setTextureRect(Rect(0, 0, size.width, size.height));
	setColor(color);
	setTag(tag);

	auto l = Label::create();
	l->setString(lable);
	l->setSystemFontSize(fontSize);
	l->setTextColor(textColor);
	addChild(l);
	l->setPosition(size.width / 2, size.height / 2);

	return true;
}
bool LoadingLayer::initWithResources(){

    bool bRet = false;
    do {
        CC_BREAK_IF(!LoadingLayer::init());
        auto winsize = Director::getInstance()->getWinSize();
        auto label = Label::create();
        label->setSystemFontSize(30);
        label->setPosition(winsize.width/2, winsize.height/2);
        label->setTag(123);
        this->addChild(label);
        currentCount = 2;
        totalCount = ToTalResCount;
        bRet = true;
        scheduleUpdate();
    }while(0);
    
    return bRet;
}
Exemple #13
0
Label* Label::createWithSystemFont(const std::string& text, const std::string& font, float fontSize, const Size& dimensions /* = Size::ZERO */, TextHAlignment hAlignment /* = TextHAlignment::LEFT */, TextVAlignment vAlignment /* = TextVAlignment::TOP */)
{
    auto ret = new (std::nothrow) Label(nullptr,hAlignment,vAlignment);

    if (ret)
    {
        ret->setSystemFontName(font);
        ret->setSystemFontSize(fontSize);
        ret->setDimensions(dimensions.width, dimensions.height);
        ret->setString(text);

        ret->autorelease();

        return ret;
    }

    delete ret;
    return nullptr;
}
void EquipmentInfo::showEquipment()
{
    if (tempEquipVector.size() == 0)
    {
        auto label = Label::create();
        label->setPosition(Point(220, 150));
        label->setString(mpFontChina->getComString("DetailNoEquip")->getCString());
        label->setSystemFontSize(18.0f);
        equipmentScrollView->addChild(label);
        return;
    }
    equipmentScrollView->removeAllChildrenWithCleanup(true);
    int cellCount = tempEquipVector.size();
    auto cell_Size = cellSize * cellScale;
    Size szInnerContainer = equipmentScrollView->getContentSize();
    int cellGap = 0;									// 滚动层cell间隔
    int cellHeightGap = 10;								// 滚动层cell间隔

    auto columuNum = cellCount / 4;
    if ( cellCount % 4 != 0 )
    {
        columuNum ++;
    }
    auto height = (cellSize.height * cellScale + cellHeightGap) * columuNum ;
    height = (height > szInnerContainer.height) ? height : szInnerContainer.height;
    equipmentScrollView->setInnerContainerSize(Size(szInnerContainer.width, height));
    for (unsigned int i = 0; i < tempEquipVector.size(); i ++)
    {
        auto nameString = __String::createWithFormat("%d.png", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eID);
        auto equip = EquipmentCell::create();
        equip->setImage(nameString->getCString());
        equip->setPosition(Point( ( i % 4 ) * (cellSize.width * cellScale + cellGap) + 10,
                                  height - ( i / 4 + 1 ) * (cellSize.height * cellScale + cellHeightGap)));
        equip->setScale(0.8f);
        equip->setTag( 100 + i );
        equip->equipmentPanel->setTag( tempEquipVector[ i ].ePKID );
        equip->equipmentPanel->setTouchEnabled(true);
        equip->equipmentPanel->addTouchEventListener(this, toucheventselector(EquipmentInfo::imageClick));
        equipmentScrollView->addChild(equip);
    }
}
Exemple #15
0
bool Loading::init()
{
	textureCacheArray = __Array::create();
	textureCacheArray->retain();

	mpFontChina = FontChina::getInstance();
	mpFontChina->initStringXml();

	

	auto spriteBG = Sprite::create("TempPic/Loading/loading1.png");
	spriteBG->setPosition(Point(400, 240));
	this->addChild(spriteBG);
	
	auto size = Director::getInstance()->getVisibleSize();
	auto spriteProgress = Sprite::create("TempPic/Loading/Loading.png");
	auto progressBar = ProgressTimer::create(spriteProgress);
	progressBar->setType(ProgressTimer::Type::BAR);
	progressBar->setMidpoint(Point::ANCHOR_BOTTOM_LEFT);
	progressBar->setBarChangeRate(Point::ANCHOR_BOTTOM_RIGHT);
	progressBar->setPosition(Point(size.width / 2, 0 + 80));
	progressBar->setPercentage(0);
	this->addChild(progressBar, 10, PROGRESSTAG);

	auto sprite2 = Sprite::create("TempPic/Loading/LoadingBG.png");
	sprite2->setPosition(Point(size.width / 2, 0 + 80));
	this->addChild(sprite2, 2);

	auto label = Label::create();
	label->setPosition(Point(400, 40));
	label->setSystemFontSize( 20.0f );
	this->addChild(label, 10);

	auto nameString = __String::createWithFormat("Loading%d", ToolFunc::calcRandom(1, 19));
	auto labelString = __String::createWithFormat("%s", mpFontChina->getComString(nameString->getCString())->getCString());
	label->setString(labelString->getCString());

	return true;
}
bool startonce::init()
{

	auto app = (AppDelegate *)(Application::getInstance()); 
	app->hideBanner();

	Size visibleSize = Director::getInstance()->getVisibleSize();
	Point origin = Director::getInstance()->getVisibleOrigin();

	auto aboutGame = DataManager::getInstance()->localOnceGameVector();


	if (UserDefault::getInstance()->getBoolForKey("firstGame") == false)
	{
		UserData::getInstance()->setupEffect = true;
		UserData::getInstance()->saveEffectState();

		UserData::getInstance()->setupMusic = true;
		UserData::getInstance()->saveMusicState();

		UserDefault::getInstance()->setBoolForKey("firstGame",true);
		for (int i = 0; i < 5; i++)
		{
			auto label  = Label::create();
			label->setPosition(Point(visibleSize.width / 2, 200 - i * 50 ));
			label->setString(String::createWithFormat("%s", aboutGame[ i ].OpenStory)->getCString());
			label->setSystemFontSize( 20.0f );
			addChild(label);

			label->runAction(Sequence::create(MoveBy::create(6.0f, Point(0, 500)),/*CallFunc::create(CC_CALLBACK_0(startonce::repScene,this)),*/NULL));

		}
		this->runAction(Sequence::createWithTwoActions( DelayTime::create( 5.0f ), CallFunc::create( CC_CALLBACK_0( startonce::repScene, this ) ) ));
		//repScene();
	}
	
    return true;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png",
                                           "CloseSelected.png",
                                           CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
                                origin.y + closeItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    auto menu = Menu::create(closeItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);


    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    auto label = Label::create();
	label->setDimensions(400, 100);
	label->setLineBreakWithoutSpace(true);
	//label->setString("123456789012345678901234567890 123456789012345678901234567890 12345678901234567890");
	label->setSystemFontName("Arial");
	label->setSystemFontSize(24);
    
    // position the label on the center of the screen
    //label->setPosition(Vec2(origin.x + visibleSize.width/2,origin.y + visibleSize.height - label->getContentSize().height));
	label->setAnchorPoint(Vec2(0, 1));
	label->setPosition(Vec2(100,100));

    // add the label as a child to this layer
    this->addChild(label, 1);

	/*TintTest*/
	/*
    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("images/380.png");
    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
	sprite->setColor(Color3B(0, 255, 0));
    // add the sprite as a child to this layer
    this->addChild(sprite, 1);
	sprite->runAction(Sequence::createWithTwoActions(TintTo::create(3, 255, 255, 0), TintTo::create(3, 255, 0, 0)));*/

	/*
	MonsterHeadSprite *monster = MonsterHeadSprite::create("и╜ажа╜йС");
	monster->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
	this->addChild(monster, 0);

	DigitSprite* digit = DigitSprite::create();
	digit->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));
	this->addChild(digit, 0);
	digit->showDigit(21);*/
	
	/*
	//dialogue layer test
	Node* stencil = Node::create();
	auto clip1 = LayerColor::create(Color4B::BLACK, 24, 24);
	clip1->setPosition(Vec2(100,76));
	stencil->addChild(clip1);

	ClippingNode* clippingNode = ClippingNode::create(stencil);
	clippingNode->addChild(sprite);
	addChild(clippingNode, 2);*/

	/*
	//CharacterLayer test
	CharacterLayer *clayer = CharacterLayer::create();
	addChild(clayer, 1, 1);*/

	/*choice menu layer
	auto layer = ChoiceLayer::create();
	layer->setAnchorPoint(Vec2(0.5, 0.5));
	layer->setPosition(Vec2(400, 300));
	addChild(layer, 2, 2);*/
	
	/*Read script file
	FileUtils::getInstance()->addSearchPath("scripts");
	if (!FileUtils::getInstance()->isFileExist("script.rpy")) {
		CCLOG("cannot find file: script.rpy.");
	}
	string s = FileUtils::getInstance()->getStringFromFile("script.rpy");
	size_t pos = s.find_first_of("\r\n");
	list<string> stmts = CommonUtils::splitString(s, "\r\n");
	label->setString(stmts.front());
*/

    return true;
}
void BackGroundLayer::LoadNode()
{
    topBG = Sprite::create("toppic.png");
    topBG->setPosition(Vec2(0, 640));
    topBG->setAnchorPoint(Vec2(0, 1));
    topBG->setScaleX(1.8750f);
    topBG->setScaleY(1.3370f);
    topBG->runAction(RepeatForever::create(Sequence::create(MoveBy::create(15, Vec2(960.0f, 0)), CallFunc::create([&](){
        topBG->setPosition(Vec2(0, 640));
    }), NULL)));
    this->addChild(topBG);

    topBGclone = Sprite::create("toppic.png");
    topBGclone->setPosition(Vec2(0, 640));
    topBGclone->setAnchorPoint(Vec2(1, 1));
    topBGclone->setScaleX(1.8750f);
    topBGclone->setScaleY(1.3370f);
    topBGclone->runAction(RepeatForever::create(Sequence::create(MoveBy::create(15, Vec2(960, 0)), CallFunc::create([&](){
        topBGclone->setPosition(Vec2(0, 640));
    }), NULL)));
    this->addChild(topBGclone);

    buttomBG = PVEffectSprite::create("miku.jpg");
    buttomBG->setPosition(Vec2(0, 0));
    buttomBG->setAnchorPoint(Vec2(0, 0));
    buttomBG->setScaleY(0.738f);
    buttomBG->setName("buttomBG");
    buttomBG->retain();
    this->addChild(buttomBG);

    //歌词结点
    auto lyrcisNode = Node::create();
    lyrcisNode->setPosition(Vec2(300.0f, 470.0f));
    lyrcisNode->setName("lyrcisNode");
    buttomBG->addChild(lyrcisNode);

    //歌词特效结点
    auto lyrcisParticleNode = Node::create();
    lyrcisParticleNode->setPosition(Vec2(300.0f, 470.0f));
    lyrcisParticleNode->setName("lyrcisParticleNode");
    buttomBG->addChild(lyrcisParticleNode);

	//初始化歌词Node,歌词Node包含5个歌词子结点
	for (int i = 0; i < 5; ++i)
	{
        auto lyrcis = Label::create();
		lyrcis->setAlignment(TextHAlignment::LEFT);
		lyrcis->setOpacity(0);//便于开始的FadeIn动作
        lyrcis->setSystemFontSize(30);
		lyrcis->setPositionY(-i * 40);
		lyrcis->setColor(Color3B{ 241, 125, 170 });
#if (CC_TARGET_PLATFORM != CC_PLATFORM_ANDROID)
		lyrcis->enableOutline(Color4B(255, 192, 203, 255), 1);
		lyrcis->enableGlow(Color4B(255, 255, 255, 255));
#endif
		lyrcisNode->addChild(lyrcis);
	}

    auto lyrcisParticl = ParticleSystemQuad::create("particle/star.plist"); //歌词特效粒子
    lyrcisParticl->setPositionY(40);
    lyrcisParticl->setTotalParticles(20);
    lyrcisParticl->setVisible(false);
	lyrcisParticl->setName("lyrcisParticle");
    lyrcisParticleNode->addChild(lyrcisParticl);


   

    //触摸粒子
    touchparticle = ParticleSystemQuad::create("particle/touch.plist");
    touchparticle->setLocalZOrder(2);
    touchparticle->ignoreAnchorPointForPosition(true);
    touchparticle->setVisible(true);
    this->addChild(touchparticle);



    //初始化魂进度条
    soulProgBar = ProgressTimer::create(Sprite::create("progressUp.png"));
    soulProgBar->setType(ProgressTimer::Type::BAR);
    soulProgBar->setPosition(Vec2(250, 550));
    soulProgBar->ignoreAnchorPointForPosition(true);
    soulProgBar->setMidpoint(Point(0, 1));
    soulProgBar->setBarChangeRate(Point(1, 0));
    soulProgBar->setPercentage(0);
    this->addChild(soulProgBar);

    //添加进度条背景
    auto soulProgBarBG = Sprite::create();
    soulProgBarBG->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("progressDown.png"));
    soulProgBarBG->setPosition(Vec2(-5, -25));
    soulProgBarBG->setAnchorPoint(Vec2(0, 0));
    soulProgBarBG->setName("soul_progBarBG");
    soulProgBarBG->setLocalZOrder(-1);
    soulProgBar->addChild(soulProgBarBG);

    scrollBar_Background = UVEffectSprite::create();  //初始化鼓面背景层
    scrollBar_Background->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("sfieldbg.png"));
    scrollBar_Background->setPosition(Vec2(92.65f, 410.83f));   //设置绝对坐标
    scrollBar_Background->setAnchorPoint(Vec2(0, 0));//设置坐标
    scrollBar_Background->setScaleX(1.6885f);
    scrollBar_Background->setScaleY(1.5645f);
    scrollBar_Background->retain();
    this->addChild(scrollBar_Background);

    scrollBar = Node::create(); //初始化鼓面
    scrollBar->setPosition(Vec2(92.65f, 410.83f));//设置绝对坐标
    scrollBar->setAnchorPoint(Vec2(0, 0));//设置坐标
    scrollBar->setScaleX(1.6885f);
    scrollBar->setScaleY(1.5645f);
    scrollBar->setContentSize(scrollBar_Background->getContentSize());//复制上一层的长度
    this->addChild(scrollBar);

    auto scrollBarGu = Node::create(); //滚动条鼓面结点
    scrollBarGu->setPosition(Vec2(0, 0));
    scrollBarGu->setLocalZOrder(2);
    scrollBar->addChild(scrollBarGu);

    scrollBarClone = Node::create();
    scrollBarClone->setName("scrollBarClone");
    scrollBarClone->setAnchorPoint(Vec2(0, 0));
    scrollBarClone->setPosition(Vec2(512, 0));
    auto scrollBarCloneGu = Node::create();//滚动副条鼓面结点
    scrollBarCloneGu->setPosition(Vec2(0, 0));
    scrollBarClone->addChild(scrollBarCloneGu);
    scrollBar->addChild(scrollBarClone);

    GUcharMap = Label::createWithCharMap("combonumber_balloon.png", 20, 24, '0');   //测试计数
    GUcharMap->setAnchorPoint(Vec2(0, 0));
    GUcharMap->setPosition(Vec2(0, -30));
    GUcharMap->setString("0");// 初始化为0分
    GUcharMap->setGlobalZOrder(4);
    scrollBar->addChild(GUcharMap);

    GUcharMapClone = Label::createWithCharMap("combonumber_balloon.png", 20, 24, '0');   //测试计数
    GUcharMapClone->setAnchorPoint(Vec2(0, 0));
    GUcharMapClone->setString("0");// 初始化为0分
    GUcharMapClone->setGlobalZOrder(4);
    GUcharMapClone->setPosition(Vec2(0, -30));
    scrollBarClone->addChild(GUcharMapClone);


#pragma region 初始游戏谱面
    for (int i = 0; i < DrumSurfaceLoader::PerDrumCount; ++i) //初始化  scrollBarGu与 scrollBarCloneGu的结点	
    {
        auto tempSprite = Sprite::create();
        tempSprite->setVisible(false);
        tempSprite->setPosition(Vec2((i % DrumSurfaceLoader::PerDrumCount) * scrollBar->getContentSize().width / DrumSurfaceLoader::PerDrumCount, 30));
        scrollBarGu->addChild(tempSprite);
        auto tempSprite2 = Sprite::create();
        tempSprite2->setVisible(false);
        tempSprite2->setPosition(Vec2((i % DrumSurfaceLoader::PerDrumCount) * scrollBar->getContentSize().width / DrumSurfaceLoader::PerDrumCount, 30));
        scrollBarCloneGu->addChild(tempSprite2);
    }
    scrollBarSpriteVector = scrollBarGu->getChildren();
    for (const auto &node : scrollBarCloneGu->getChildren())
    {
        scrollBarSpriteVector.pushBack(node);
    }
#pragma endregion

}
void EquipmentInfo::singleEquipmentInfo(int pkID, int typeClick)
{
    equipmentPKID = pkID;
    for (unsigned int i = 0; i < tempEquipVector.size(); i ++)
    {
        if (tempEquipVector[ i ].ePKID == pkID)
        {
            auto singlePanel = dynamic_cast<Layout* >(Helper::seekWidgetByName(singleInfo, "Panel_Left"));								// 获取属性面板
            auto nameImageString = __String::createWithFormat("%d.png", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eID);
            auto nameImage = dynamic_cast<ImageView* >(Helper::seekWidgetByName(singlePanel, "Image_Equip_0"));						// 设置物品图片
            nameImage->loadTexture(nameImageString->getCString(), TextureResType::UI_TEX_TYPE_PLIST);
            nameImage->setScale(81.0f / 120.0f);
            auto nameText = dynamic_cast<Text* >(Helper::seekWidgetByName(singlePanel, "Label_Name"));								// 装备名称
            if (tempEquipVector[ i ].eLevel == 0)
            {
                auto equipLevel = __String::createWithFormat("%s", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eChinaName);
                nameText->setText(equipLevel->getCString());
            }
            else
            {
                auto equipLevel = __String::createWithFormat("%s+%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eChinaName, tempEquipVector[ i ].eLevel);
                nameText->setText(equipLevel->getCString());
            }
            for (int z = 60; z < 62; z ++)
            {
                singlePanel->removeChildByTag( z );
            }
            // 功能按钮
            auto equipButton = dynamic_cast<Button*>(Helper::seekWidgetByName(singlePanel, "Button_Equip"));						// 装备按钮
            equipButton->addTouchEventListener(this, toucheventselector(EquipmentInfo::equipClick));
            equipButton->setVisible(false);
            equipButton->setTouchEnabled(false);

            auto changeButton = dynamic_cast<Button*>(Helper::seekWidgetByName(singlePanel, "Button_Change"));					// 更换
            changeButton->addTouchEventListener(this, toucheventselector(EquipmentInfo::changeClick));
            changeButton->setVisible(false);
            changeButton->setTouchEnabled(false);

            auto unloadButton = dynamic_cast<Button*>(Helper::seekWidgetByName(singlePanel, "Button_Unload"));					// 卸下
            unloadButton->addTouchEventListener(this, toucheventselector(EquipmentInfo::unloadClick));
            unloadButton->setVisible(false);
            unloadButton->setTouchEnabled(false);
            if (interGeneralEquipVector[ 0 ].equipID[ DataManager::getInstance()->equipType - 1 ] == 0)							// 点击的位置没有装备
            {
                equipButton->setVisible(true);
                equipButton->setTouchEnabled(true);

                if (false == NewComer::isGuideDone(1000))						/* 引导ID为0,且未完成 */
                {
                    _comer = NewComer::create(this, 1000, 4);
                }
            }
            else
            {
                if ( interGeneralEquipVector[ 0 ].equipPKID[ DataManager::getInstance()->equipType - 1 ] == pkID )
                {
                    unloadButton->setVisible(true);
                    unloadButton->setTouchEnabled(true);
                }
                else
                {
                    changeButton->setVisible(true);
                    changeButton->setTouchEnabled(true);
                }
            }

            // 物品属性
            auto proptyLabel1 = (Text*)singlePanel->getChildByName("Label_Propty_1");
            proptyLabel1->setFontSize(FontSize);
            proptyLabel1->setVisible(false);
            auto proptyLabel2 = (Text*)singlePanel->getChildByName("Label_Propty_2");
            proptyLabel2->setFontSize(FontSize);
            proptyLabel2->setVisible(false);
            auto label1 = Label::create();
            label1->setSystemFontSize(FontSize);
            label1->setColor(Color3B(255, 76, 0));
            label1->setTag(Label1);
            singlePanel->addChild(label1, 10);
            auto label2 = Label::create();
            label2->setSystemFontSize(FontSize);
            label2->setColor(Color3B(255, 76, 0));
            label2->setTag(Label2);
            singlePanel->addChild(label2, 10);

            auto goodsTypeString = __String::createWithFormat("%s", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].ePositionName);
            auto goodsDesString = __String::createWithFormat("%s", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eDes);
            auto typeLabel = dynamic_cast<Text*>(Helper::seekWidgetByName(singlePanel, "Label_Num"));
            auto desLabel = (Text*)singlePanel->getChildByName("Label_Des");
            typeLabel->setVisible(true);
            typeLabel->setText(goodsTypeString->getCString());

            desLabel->setVisible(true);
            desLabel->ignoreContentAdaptWithSize(false);
            desLabel->setSize(Size(180, 150));
            desLabel->setTextHorizontalAlignment(TextHAlignment::LEFT);
            desLabel->setText(goodsDesString->getCString());
            switch (localEquipVector[ tempEquipVector[ i ].eID - 94001 ].ePositionType)
            {
            case PosTypeHead:
            {
                proptyLabel1->setVisible(true);
                proptyLabel2->setVisible(false);
                proptyLabel1->setText(mpFontChina->getComString("PD")->getCString());

                auto hpString = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].ePD);
                label1->setPosition(Point(proptyLabel1->getPositionX() + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPositionY()));
                label1->setString(hpString->getCString());
            }
            break;
            case PosTypeArmour:
            {
                proptyLabel1->setVisible(true);
                proptyLabel2->setVisible(false);
                proptyLabel1->setText(mpFontChina->getComString("HP")->getCString());

                auto hpString = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eHP);
                label1->setPosition(Point(proptyLabel1->getPositionX() + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPositionY()));
                label1->setString(hpString->getCString());
            }
            break;
            case PosTypeDecorations:
            {
                proptyLabel1->setVisible(true);
                proptyLabel1->setText(mpFontChina->getComString("MD")->getCString());
                proptyLabel2->setVisible(false);
                auto attackString = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eMD);
                label1->setPosition(Point(proptyLabel1->getPositionX() + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPositionY()));
                label1->setString(attackString->getCString());
            }
            break;
            case PosTypeWeapons:
            {
                proptyLabel1->setVisible(true);
                proptyLabel2->setVisible(false);
                proptyLabel1->setText(mpFontChina->getComString("Attack")->getCString());
                label1->setPosition(proptyLabel1->getPosition().x + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPosition().y);
                auto hpString = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eAtk);
                label1->setString(hpString->getCString());
            }
            break;
            case PosTypeQi:
            {
                proptyLabel1->setVisible(true);
                proptyLabel2->setVisible(true);
                proptyLabel1->setText(mpFontChina->getComString("APR")->getCString());
                label1->setPosition(proptyLabel1->getPosition().x + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPosition().y);
                auto hpString = __String::createWithFormat("%.2f", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eAddCrit);
                label1->setString(hpString->getCString());

                proptyLabel2->setText(mpFontChina->getComString("RPR")->getCString());
                label2->setPosition(proptyLabel2->getPosition().x + proptyLabel2->getContentSize().width + 10, proptyLabel2->getPosition().y);
                auto hpString2 = __String::createWithFormat("%.2f", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eReduceCrit);
                label2->setString(hpString2->getCString());
            }
            break;
            case PosTypeYi:
            {
                proptyLabel1->setVisible(true);
                proptyLabel2->setVisible(true);
                proptyLabel1->setText(mpFontChina->getComString("ARH")->getCString());
                label1->setPosition(proptyLabel1->getPosition().x + proptyLabel1->getContentSize().width + 10, proptyLabel1->getPosition().y);
                auto hpString = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eAddRealHurt);
                label1->setString(hpString->getCString());

                proptyLabel2->setText(mpFontChina->getComString("RRH")->getCString());
                label2->setPosition(proptyLabel2->getPosition().x + proptyLabel2->getContentSize().width + 10, proptyLabel2->getPosition().y);
                auto hpString2 = __String::createWithFormat("%d", localEquipVector[ tempEquipVector[ i ].eID - 94001 ].eReduceHurt);
                label2->setString(hpString2->getCString());
            }
            break;
            }
        }
    }
}
// on "init" you need to initialize your instance
bool Pause::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !LayerColor::initWithColor(Color4B(0,0,0,50),800,480) )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    //adding menu items
    auto Exit=MenuItemFont::create("Exit",CC_CALLBACK_1(Pause::Exit,this));
    auto Resume=MenuItemFont::create("Resume",CC_CALLBACK_1(Pause::Resume,this));
    Exit->setColor(Color3B(0,0,0));
    Exit->setFontSizeObj(40.0);
    Resume->setColor(Color3B(0,0,0));
    Resume->setFontSizeObj(40.0);

    //adding labels that will clarify graphic buttons' meanings
    auto MusicT=Label::create();
    auto AudioT=Label::create();
    MusicT->setString("Music");
    AudioT->setString("Audio");
    MusicT->setSystemFontSize(40.0);
    AudioT->setSystemFontSize(40.0);
    MusicT->setColor(Color3B(0,0,0));
    AudioT->setColor(Color3B(0,0,0));
    MusicT->setPosition(Point(visibleSize.width/2-50,(visibleSize.height/5)*4));
    AudioT->setPosition(Point(visibleSize.width/2-50,(visibleSize.height/5)*3));
    this->addChild(MusicT);
    this->addChild(AudioT);

    //creating grahic buttons
    auto MusicON=MenuItemImage::create("MUSICON.png","MUSICON.png");
    auto MusicOFF=MenuItemImage::create("MUSICOFF.png","MUSICOFF.png");
    auto AudioON=MenuItemImage::create("MUSICON.png","MUSICON.png");
    auto AudioOFF=MenuItemImage::create("MUSICOFF.png","MUSICOFF.png");

    //adding toggles to support two-state graphic buttons
    auto ToggleM=MenuItemToggle::createWithCallback(CC_CALLBACK_1(Pause::SwitchMusic,this),MusicON,MusicOFF,NULL);
    auto ToggleA=MenuItemToggle::createWithCallback(CC_CALLBACK_1(Pause::SwitchAudio,this),AudioON,AudioOFF,NULL);

    //setting items' positions
    ToggleM->setPosition(Point(visibleSize.width/2+50,(visibleSize.height/5)*4));
    ToggleA->setPosition(Point(visibleSize.width/2+50,(visibleSize.height/5)*3));
    Resume->setPosition(Point(visibleSize.width/2+50,(visibleSize.height/5)*2));
    Exit->setPosition(Point(visibleSize.width/2+50,(visibleSize.height/5)*1));

    //making sure that graphics will be displayed properly for disabled music/audio
    MusicD& md=MusicD::getHandle();

    if(!md.GetIsMusicPlaying())
    {
    	ToggleM->setSelectedIndex(1);
    }
    if(!md.GetIsAudioPlaying())
    {
    	ToggleA->setSelectedIndex(1);
    }

    //adding menu
    auto *menu=Menu::create(ToggleA,ToggleM,Resume,Exit,NULL);
    menu->setPosition(Point(0,0));
    this->addChild(menu);

    //adding touch swallowing event listener
    auto listener = EventListenerTouchOneByOne::create();
    listener->setSwallowTouches(true);
    listener->onTouchBegan=CC_CALLBACK_2(Pause::onTouchBegan,this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener,this);

    return true;
}