Пример #1
0
void GameStart::showHistorySorceNumber()
{
	// Game Data
	int sorceNumber = 100;
	LabelAtlas * labelNumber = LabelAtlas::create(String::createWithFormat("%d",sorceNumber)->_string,"fh_shuzi.png",22,32,48);
	labelNumber->setAnchorPoint(Vec2(0.0, 0.5));
	labelNumber->setPosition(Vec2(visibleSize.width / 2 + 50, visibleSize.height / 2 - 150));
	addChild(labelNumber);
}
Пример #2
0
void GameStart::showCurrcertSorceNumber()
{
	// GameData
	int currcertSorce = GameData::getInstance()->getCurrcertSorce();
	LabelAtlas * CurrcertSorce = LabelAtlas::create(String::createWithFormat("%d", currcertSorce)->_string, "yx_shuzi.png", 18, 24, 48);
	CurrcertSorce->setAnchorPoint(Vec2(0.0, 0.5));
	CurrcertSorce->setPosition(Vec2(visibleSize.width / 2 + 120, visibleSize.height / 2 + 330));
	addChild(CurrcertSorce);
}
Пример #3
0
void GameShopLayer::showGoldNumber()
{
	// GameData
	int goldNumber = 1000;
	LabelAtlas * goldLabel = LabelAtlas::create(String::createWithFormat("%d", goldNumber)->_string, "gameShop/sc_shuzi.png",14,19,48);
	goldLabel->setAnchorPoint(Vec2(0.0, 0.5));
	goldLabel->setPosition(Vec2(visibleSize.width / 2 - 120, visibleSize.height / 2 + 157));
	addChild(goldLabel);
}
Пример #4
0
bool GameGuiLayer::init() {
    if (!Layer::init())
    {
        return false;
    }
    gotoResultLayer = false;
    Size visibleSize = Director::getInstance()->getVisibleSize();
    //add pause btn to this layer
    MenuItemImage* start_btn = MenuItemImage::create(
                                   "btn_setting.png", "btn_setting.png", CC_CALLBACK_0(GameGuiLayer::pauseGame, this));
    Menu* start_game = Menu::create(start_btn, NULL);
    start_game->setPosition(visibleSize.width - 30, visibleSize.height - 30);
    this->addChild(start_game);
    //add player score
    playerScore = LabelAtlas::create(
                      cocos2d::String::createWithFormat("%d", GAMEDATA::getInstance()->getScore())->_string, "game_result_score_num.png", 49, 70, '0');
    playerScore->setScale(0.8f);
    playerScore->setAnchorPoint(ccp(0.5, 0.5));
    playerScore->setPosition(ccp(240, 760));
    this->addChild(playerScore);
    //init palyer time
    initTime();

    //add time progress
    gameSlioder = GameSlioder::create();
    gameSlioder->setAnchorPoint(ccp(0, 0));
    gameSlioder->setPosition(ccp(0, 0));
    this->addChild(gameSlioder);
    //add play time
    LabelAtlas* zero = LabelAtlas::create("00", "time_num.png", 17, 20, '0');
    zero->setPosition(ccp(195, 695));
    this->addChild(zero);

    Sprite* devide = Sprite::create("time_devide_icon.png");
    devide->setPosition(ccp(234, 707));
    this->addChild(devide);
    std::string time_string = "";
    if (totalTime - passTime < 10) {
        std::string time_string = "0";
    }
    palyTime = LabelAtlas::create(time_string +
                                  cocos2d::String::createWithFormat("%d", (int)(totalTime - passTime))->_string, "time_num.png", 17, 20, '0');
    palyTime->setPosition(ccp(240, 695));
    this->addChild(palyTime);
    scheduleUpdate();
    schedule(schedule_selector(GameGuiLayer::updateTime), 1.0f, kRepeatForever, 0);
    return true;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    
	Size visibleSize = Director::getInstance()->getVisibleSize();

	MenuItemFont* pIncrease = MenuItemFont::create("increase 20",CC_CALLBACK_1(HelloWorld::increaseCallback,this));
	pIncrease->setAnchorPoint(Vec2(0.0f,1.0f));
	pIncrease->setPosition(0.0f,visibleSize.height - 0.0f);


	MenuItemFont* pReduce   = MenuItemFont::create("reduce 20",CC_CALLBACK_1(HelloWorld::reduceCallback,this));
	pReduce->setAnchorPoint(Vec2(0.0f,1.0f));
	pReduce->setPosition(0.0f,visibleSize.height - 40.0f);

	MenuItemFont* pGoto     = MenuItemFont::create("goto 100",CC_CALLBACK_1(HelloWorld::gotoCallback,this));
	pGoto->setAnchorPoint(Vec2(0.0f,1.0f));
	pGoto->setPosition(0.0f,visibleSize.height - 80.0f);

	Menu* pMenu = Menu::create(pIncrease,pReduce,pGoto, NULL);
	pMenu->setPosition(Vec2(0.0f,0.0f));
    this->addChild(pMenu, 1);


	LabelAtlas* pNumber = LabelAtlas::create("","number.png",55,84,'0');
	pNumber->setAnchorPoint(Vec2(0.5f,0.5f));
	pNumber->setPosition(Vec2(visibleSize.width/2.0f,
                             visibleSize.height/2.0f));

	this->addChild(pNumber);

	m_numberCount.setLabelAtlas(pNumber); //如果是从cocostudio导出的话请调用NumberCount::setTextAtlas

	//将数字每一步的增量初始化为3
	m_numberCount.setNumberDelta(3);

	//将数字增加时间间隔设置为0.1秒
	m_numberCount.setTimeDelta(0.1f);

	//将数字初始化为100
	m_numberCount.setNumber(100,false);
    return true;
}
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
    //srandom(0);

    subtestNumber = asubtest;
    Size s = Director::getInstance()->getWinSize();

    lastRenderedCount = 0;
    quantityParticles = particles;

    MenuItemFont::setFontSize(65);
    MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) {
		quantityParticles -= kNodesIncrease;
		if( quantityParticles < 0 )
			quantityParticles = 0;

		updateQuantityLabel();
		createParticleSystem();
	});
    decrease->setColor(Color3B(0,200,20));
    MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) {
		quantityParticles += kNodesIncrease;
		if( quantityParticles > kMaxParticles )
			quantityParticles = kMaxParticles;

		updateQuantityLabel();
		createParticleSystem();
	});
    increase->setColor(Color3B(0,200,20));

    Menu *menu = Menu::create(decrease, increase, NULL);
    menu->alignItemsHorizontally();
    menu->setPosition(Point(s.width/2, s.height/2+15));
    addChild(menu, 1);

    LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30);
    infoLabel->setColor(Color3B(0,200,20));
    infoLabel->setPosition(Point(s.width/2, s.height - 90));
    addChild(infoLabel, 1, kTagInfoLayer);

    // particles on stage
    LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
    addChild(labelAtlas, 0, kTagLabelAtlas);
    labelAtlas->setPosition(Point(s.width-66,50));

    // Next Prev Test
    ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
    addChild(menuLayer, 1, kTagMenuLayer);
    menuLayer->release();

    // Sub Tests
    MenuItemFont::setFontSize(40);
    Menu* pSubMenu = Menu::create();
    for (int i = 1; i <= 6; ++i)
    {
        char str[10] = {0};
        sprintf(str, "%d ", i);
        MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this));
        itemFont->setTag(i);
        pSubMenu->addChild(itemFont, 10);

        if (i <= 3)
        {
            itemFont->setColor(Color3B(200,20,20));
        }
        else
        {
            itemFont->setColor(Color3B(0,200,20));
        }
    }
    pSubMenu->alignItemsHorizontally();
    pSubMenu->setPosition(Point(s.width/2, 80));
    addChild(pSubMenu, 2);

    LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40);
    addChild(label, 1);
    label->setPosition(Point(s.width/2, s.height-32));
    label->setColor(Color3B(255,255,40));

    updateQuantityLabel();
    createParticleSystem();

    schedule(schedule_selector(ParticleMainScene::step));
}