Beispiel #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);
}
Beispiel #2
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);
}
Beispiel #3
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);
}
// 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;
}