Exemplo n.º 1
0
ControlButton* standardButtonWithTitle( const char * bgname, const char * bgseledname, const char * title){

	//Creates and return a button with a default background and title color.
//    Scale9Sprite *backgroundButton = Scale9Sprite::create(bgname);//按下前
//    Scale9Sprite *backgroundHighlightedButton = Scale9Sprite::create(bgseledname);//按下后
	

	ControlButton* btn = ControlButton::create();
	btn->setPreferredSize(Size(522, 88));

	Scale9Sprite*	normal = Scale9Sprite::create(bgname);
	Scale9Sprite*	select = Scale9Sprite::create(bgseledname);
	Scale9Sprite* hightlight = Scale9Sprite::create(bgseledname);
	Scale9Sprite* disable = Scale9Sprite::create(bgname);
	
	btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
	btn->setBackgroundSpriteForState(select, Control::State::SELECTED);
	btn->setBackgroundSpriteForState(hightlight, Control::State::HIGH_LIGHTED);
	btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
	
	
    LabelTTF *titleButton = LabelTTF::create(title, "AmericanTypewriter", 30);//添加文字
	titleButton->setAnchorPoint(Point(0.5f, 0.5f));
	titleButton->setPosition(Point(btn->getContentSize().width/2, btn->getContentSize().height/2));
	titleButton->setColor(Color3B::BLACK);//设置文字点击前的颜色
	titleButton->setTag(1000);
	btn->addChild(titleButton);

    return btn;
}
Exemplo n.º 2
0
void AssetsUpdateLayer::updateLayerMessageBox()
{

    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("ccb/ccbResources/SystemLoading.plist");

    CCLayer* layer = CCLayer::create();
    layer->ignoreAnchorPointForPosition(false);
    layer->setContentSize(Size(960, 640));
    layer->setPosition(Point(Director::getInstance()->getWinSize().width * 0.5, Director::getInstance()->getWinSize().height * 0.5));
    layer->setScale(Director::getInstance()->getWinSize().width / 960);
    addChild(layer, 1);

    Sprite* messageboxSprite = Sprite::createWithSpriteFrameName("set_floor_v1.png");
    messageboxSprite->setPosition(Point(480, 320));
    layer->addChild(messageboxSprite, 1);

    LabelTTF* labelContent = LabelTTF::create(Localization::getInstance()->getValueByKey("Loading_warning_need_update"), "Helvetica",32);
    labelContent->setPosition(Point(480, 420));
    layer->addChild(labelContent, 1);

    ControlButton* btn = ControlButton::create(LabelTTF::create(Localization::getInstance()->getValueByKey("BUTTON_DONE"), "Helvetica", 32), Scale9Sprite::createWithSpriteFrameName("set_button2.png"));
    btn->setPreferredSize(CCSize(191,70));
    btn->setPosition(Point(480, 220));
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(AssetsUpdateLayer::GoToAppPage), Control::EventType::TOUCH_UP_INSIDE);
    layer->addChild(btn, 1);

}
Exemplo n.º 3
0
bool SkillTableView::init()
{
    if (!Node::init())
        return false;

    LayerColor* bg = LayerColor::create(Color4B(255, 255, 255, 127), 450, 500);
    bg->setPosition(bg->getContentSize()/-2);
    this->addChild(bg, -1);
    
    CCLabelTTF* title = CCLabelTTF::create("技能列表", "fonts/Marker Felt.ttf", 40);
    title->setPosition(Point(bg->getContentSize().width/2, bg->getContentSize().height-30));
    bg->addChild(title);
    
    ControlButton* button = ControlButton::create(Scale9Sprite::create("ui/closed_normal.png"));
    button->setBackgroundSpriteForState(Scale9Sprite::create("ui/closed_selected.png"), Control::State::HIGH_LIGHTED);
    button->setPreferredSize(Size(57, 58));
    button->setPosition(ccpSub(ccpAdd(bg->getPosition(), bg->getContentSize()), button->getContentSize()/2));
    this->addChild(button);
    button->addTargetWithActionForControlEvents(GAME_UILAYER, cccontrol_selector(GameInfoUIController::removeSmallMenuAndButton), Control::EventType::TOUCH_UP_INSIDE);
   // button->setTouchPriority(0);
    
    m_skillTableView = TableView::create(this, Size(420, 420));
    m_skillTableView->setPosition(Point(15, 15));
   // m_skillTableView->setDirection(kCCScrollViewDirectionVertical);
    m_skillTableView->setDelegate(this);
   // m_skillTableView->setVerticalFillOrder(kCCTableViewFillTopDown);
    bg->addChild(m_skillTableView);
    m_skillTableView->reloadData();
    return true;
}
Exemplo n.º 4
0
bool PropColumnMenu::init()
{
    if (!Layer::init())
        return false;
    
    this->setTouchEnabled(true);
    
    Sprite* bg = Sprite::create("ui/prop_column.png");
    this->addChild(bg);
    
    m_propColumn = LayerColor::create(ccc4(255, 255, 255, 0), GRID_WIDTH*COL, GRID_HEIGHT*ROW);
    m_propColumn->setContentSize(Size(GRID_WIDTH*COL, GRID_HEIGHT*ROW));
    m_propColumn->setPosition(Point(PROP_X, PROP_Y));
    bg->addChild(m_propColumn);
    
    ControlButton* button = ControlButton::create(ui::Scale9Sprite::create("ui/closed_normal.png"));
    button->setBackgroundSpriteForState(ui::Scale9Sprite::create("ui/closed_selected.png"), Control::State::HIGH_LIGHTED);
    button->setPreferredSize(Size(57, 58));
    button->setPosition(ccpSub(ccpAdd(bg->getPosition(), bg->getContentSize()/2), button->getContentSize()/2));
    this->addChild(button);
    button->addTargetWithActionForControlEvents(GAME_UILAYER, cccontrol_selector(GameInfoUIController::removeSmallMenuAndButton), Control::EventType::TOUCH_UP_INSIDE);
   // button->setTouchPriority(0);
    
    for (int i=0; i<12; i++)
    {
        m_propVec[i] = PropIconShow::create(PropSystem::getPropInfo(i+1));
        m_propColumn->addChild(m_propVec[i]);
    }

    return true;
}
Exemplo n.º 5
0
ControlButton * createBtn(float x, float y, 
						  const char * normalBg, const char * pressBg, 
						  Ref* target, Control::Handler action)
{
	Scale9Sprite * spNormalBg = createDotaScale9Sprite(normalBg);
	Scale9Sprite * spPressBg = createDotaScale9Sprite(pressBg);

	ControlButton *btn = ControlButton::create(spNormalBg);
	if (spPressBg)
		btn->setBackgroundSpriteForState(spPressBg, Control::State::HIGH_LIGHTED);
	btn->setAnchorPoint(Vec2(0, 0));
	btn->setPosition(x, y);
	btn->setZoomOnTouchDown(false);
	btn->setPreferredSize(spNormalBg->getOriginalSize());
	if (target && action)
		btn->addTargetWithActionForControlEvents(target, action, 
			Control::EventType::TOUCH_UP_INSIDE);

	return btn;
}
Exemplo n.º 6
0
ControlButton* ButtonUtils::createButton(const char *normalFrame, 
										 const char *highLightFrame,
										 const char *disableFrame,
										 cocos2d::Size size,
										 const char *label,
										 float labelSize,
										 Color3B labelColor)
{
    Scale9Sprite *normal = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(normalFrame));
    Scale9Sprite *highLight = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(highLightFrame));
    Scale9Sprite *disable = Scale9Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(disableFrame));
    ControlButton *btn = ControlButton::create(label, "Arial", labelSize);
    btn->setPreferredSize(size);//设置按钮首选大小
    btn->setBackgroundSpriteForState(normal, Control::State::NORMAL);
    btn->setBackgroundSpriteForState(highLight, Control::State::HIGH_LIGHTED);
    btn->setBackgroundSpriteForState(disable, Control::State::DISABLED);
    btn->setTitleColorForState(labelColor, Control::State::NORMAL);
    btn->setTitleColorForState(labelColor, Control::State::HIGH_LIGHTED);
    btn->setTitleColorForState(labelColor, Control::State::DISABLED);
    //btn->setTouchPriority(0);
    
    return btn;
}
Exemplo n.º 7
0
// 初始化
bool ChangeBGScene::init()
{
	if (!Layer::init())
	{
		return false;
	}
	Size mysize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	//文字提示
	Sprite *lb = Sprite::create("changbg.png");
	lb->setPosition(Vec2(origin.x + mysize.width / 2, origin.y + mysize.height - 30));
	this->addChild(lb, 2);

	//四张背景图
	//1
	Scale9Sprite *sp1 = Scale9Sprite::create("11.png");
	ControlButton *pbt1 = ControlButton::create(sp1);
	pbt1->setPosition(Vec2(origin.x + mysize.width / 2 - 80, origin.y + mysize.height / 2 + 20));
	pbt1->setPreferredSize(Size(150, 84));
	this->addChild(pbt1, 2, 6001);
	//绑定事件
	pbt1->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(ChangeBGScene::changeBG),
		Control::EventType::TOUCH_UP_INSIDE);
	//2
	Scale9Sprite *sp2 = Scale9Sprite::create("22.png");
	ControlButton *pbt2 = ControlButton::create(sp2);
	pbt2->setPosition(Vec2(origin.x + mysize.width / 2 + 80, origin.y + mysize.height / 2 + 20));
	pbt2->setPreferredSize(Size(150, 84));
	this->addChild(pbt2, 2, 6002);
	//绑定事件
	pbt2->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(ChangeBGScene::changeBG),
		Control::EventType::TOUCH_UP_INSIDE);
	//3
	Scale9Sprite *sp3 = Scale9Sprite::create("33.png");
	ControlButton *pbt3 = ControlButton::create(sp3);
	pbt3->setPosition(Vec2(origin.x + mysize.width / 2 - 80, origin.y + mysize.height / 2 - 80));
	pbt3->setPreferredSize(Size(150, 84));
	this->addChild(pbt3, 2, 6003);
	//绑定事件
	pbt3->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(ChangeBGScene::changeBG),
		Control::EventType::TOUCH_UP_INSIDE);
	//4
	Scale9Sprite *sp4 = Scale9Sprite::create("44.png");
	ControlButton *pbt4 = ControlButton::create(sp4);
	pbt4->setPosition(Vec2(origin.x + mysize.width / 2 + 80, origin.y + mysize.height / 2 - 80));
	pbt4->setPreferredSize(Size(150, 84));
	this->addChild(pbt4, 2, 6004);
	//绑定事件
	pbt4->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(ChangeBGScene::changeBG),
		Control::EventType::TOUCH_UP_INSIDE);

	//返回菜单
	Scale9Sprite *spbk = Scale9Sprite::create("return.png");
	ControlButton *pbtbk = ControlButton::create(spbk);
	pbtbk->setPosition(Vec2(origin.x + mysize.width - 20, origin.y + mysize.height - 20));
	pbtbk->setPreferredSize(Size(36, 36));
	this->addChild(pbtbk, 2);
	//绑定事件
	pbtbk->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(ChangeBGScene::backToMenu),
		Control::EventType::TOUCH_UP_INSIDE);

	return true;
}
Exemplo n.º 8
0
// 初始化
bool RankScene::init()
{
	if (!Layer::init())
	{
		return false;
	}

	selected = 3001;
	opt = "easy";
	scheduleUpdate();

	Size mysize = Director::getInstance()->getVisibleSize();
	Vec2 origin = Director::getInstance()->getVisibleOrigin();

	//背景图片
	Sprite *pbg = Sprite::create("rank_bg.png");
	pbg->setPosition(Vec2(origin.x + mysize.width / 2, origin.y + mysize.height / 2));
	this->addChild(pbg, -1);

	//返回按钮
	Scale9Sprite *spback = Scale9Sprite::create("close.png");
	ControlButton *pbtbk = ControlButton::create(spback);
	pbtbk->setPosition(Vec2(origin.x + mysize.width - 20, origin.y + mysize.height - 25));
	pbtbk->setPreferredSize(Size(36, 36));
	pbtbk->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(RankScene::backToMenu),
		Control::EventType::TOUCH_UP_INSIDE);
	this->addChild(pbtbk);

	//rank_easy , tag = 3001
	Scale9Sprite *speasy = Scale9Sprite::create("easy.png");
	ControlButton *rkeasy = ControlButton::create(speasy);
	rkeasy->setPosition(Vec2(origin.x + 40, origin.y + mysize.height / 2 + 50));
	rkeasy->setPreferredSize(Size(75, 50));
	rkeasy->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(RankScene::showRank),
		Control::EventType::TOUCH_UP_INSIDE);
	this->addChild(rkeasy, 1, 3001);

	//rank_normal , tag = 3002
	Scale9Sprite *spnormal = Scale9Sprite::create("normal.png");
	ControlButton *rknormal = ControlButton::create(spnormal);
	rknormal->setPosition(Vec2(origin.x + 40, origin.y + mysize.height / 2 - 20));
	rknormal->setPreferredSize(Size(75, 50));
	rknormal->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(RankScene::showRank),
		Control::EventType::TOUCH_UP_INSIDE);
	this->addChild(rknormal, 1, 3002);

	//rank_hard tag = 3003
	Scale9Sprite *sphard = Scale9Sprite::create("hard.png");
	ControlButton *rkhard = ControlButton::create(sphard);
	rkhard->setPosition(Vec2(origin.x + 40, origin.y + mysize.height / 2 - 90));
	rkhard->setPreferredSize(Size(75, 50));
	rkhard->addTargetWithActionForControlEvents(
		this,
		cccontrol_selector(RankScene::showRank),
		Control::EventType::TOUCH_UP_INSIDE);
	this->addChild(rkhard, 1, 3003);

	TableView * tbeasy = TableView::create(this, Size(360, 200));
	tbeasy->setDirection(ScrollView::Direction::VERTICAL);
	tbeasy->setPosition(Vec2(origin.x + 90, origin.y + 15));
	tbeasy->setDelegate(this);
	tbeasy->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tbeasy, 1, 3005);

	return true;
}