bool GeneralDialogTest::init()
{
    if (CCLayer::init())
    {
        //正常状态按钮
        CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
        //按下效果
        CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
        //按钮的大小根据标题变化
        CCLabelTTF *titleButton = CCLabelTTF::create("Touch Me!", "Marker Felt", 30);
        //按钮颜色
        titleButton->setColor(ccc3(159, 168, 176));
        
        CCControlButton* controlButton = CCControlButton::create(titleButton, backgroundButton);
        controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
        controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
        
//        controlButton->setAnchorPoint(ccp(0.5f, 1));
        controlButton->setPosition(ccp(640/2, 960/5));
        addChild(controlButton);
        /* 当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次 */
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(GeneralDialogTest::touchUpInside), CCControlEventTouchUpInside);
        return true;
    }
    return false;
}
CCTableViewCell* RPGMapItemsMenuLayer::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
    CCTableViewCell *cell = tableView->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
        cell->removeAllChildrenWithCleanup(true);
    
    float x = 100;
    for (int i = 0; i < 4; i++)
    {
        int index = idx * 4 + i;
        
        if(index >= this->m_itemsList->count())
            break;
        
        RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(index);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(x, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
        x += 200;
    }
    
    return cell;
}
Exemple #3
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->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
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

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

    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

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

	CCRect rect1(133, 333, 42, 46);
	CCScale9Sprite* btnNormal = CCScale9Sprite::create("char_bluelight.png",rect1);  
	CCScale9Sprite* btnDown = CCScale9Sprite::create("char_bluelight.png",rect1);  
	CCControlButton* controlBtn = CCControlButton::create(btnNormal);  
	controlBtn->setBackgroundSpriteForState(btnDown, CCControlStateSelected);  
	controlBtn->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));  
	controlBtn->setPreferredSize(CCSize(60, 50));  
	controlBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown);
	this->addChild(controlBtn);  
    
    return true;
}
bool ParticleTest::init(){
    CCControlButton *btn = CCControlButton::create("particle ", "Arial", 24);
    btn->setPosition(ccp(320, 1000));
    this->addChild(btn);
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ParticleTest::btnClick), CCControlEventTouchDown);
    
    
    return true;
}
bool HelloScene::init()
{
    if (!CCLayer::init())
    {
        return false;
    }

    CCSprite *bg = CCSprite::create("background.png");
    bg->setPosition(VisibleRect::center());
    //CCSize &winSize = CCDirector::sharedDirector()->getWinSize();
    //float scalex = winSize.width / 480;
    //float scaley = winSize.height / 800;
    //bg->setScaleX(scalex);
    //bg->setScaleY(scaley);
    addChild(bg);

    const CCPoint &center = VisibleRect::center();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
        "CloseNormal.png",
        "CloseSelected.png",
        this,
        menu_selector(HelloScene::menuCloseCallback));
    pCloseItem->setPosition(ccp(VisibleRect::rightBottom().x - pCloseItem->getContentSize().width/2 ,
        pCloseItem->getContentSize().height/2));
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF *title = CCLabelTTF::create("Lovexin Plane Chess", "Arial", 40);
    title->setPosition(ccp(center.x, center.y + 250));
    CCLabelTTF *author = CCLabelTTF::create("made by Waltz Duyf", "Arial", 20);
    author->setPosition(ccp(center.x + 100, center.y + 200));
    addChild(title);
    addChild(author);

    addSetupSwitch(ccp(center.x - 120, center.y + 50 ), "RED", ccc3(255, 0, 0), FORCE_COLOR_RED);//, cccontrol_selector(HelloScene::valueChangedJoinInR), cccontrol_selector(HelloScene::valueChangedAIR));
    addSetupSwitch(ccp(center.x - 120, center.y - 10 ), "YEL", ccc3(234, 165, 0), FORCE_COLOR_YELLOW);//, cccontrol_selector(HelloScene::valueChangedJoinInY), cccontrol_selector(HelloScene::valueChangedAIY));
    addSetupSwitch(ccp(center.x - 120, center.y - 70 ), "GRE", ccc3(0, 255, 0), FORCE_COLOR_GREEN);//, cccontrol_selector(HelloScene::valueChangedJoinInG), cccontrol_selector(HelloScene::valueChangedAIG));
    addSetupSwitch(ccp(center.x - 120, center.y - 130), "BLU", ccc3(0, 144, 255), FORCE_COLOR_BLUE);//, cccontrol_selector(HelloScene::valueChangedJoinInB), cccontrol_selector(HelloScene::valueChangedAIB));

    CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
    CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
    CCLabelTTF *titleButton = CCLabelTTF::create("Play Now", "Arial", 30);
    titleButton->setColor(ccc3(159, 168, 176));
    CCControlButton *button = CCControlButton::create(titleButton, backgroundButton);
    button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
    button->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
    button->setMargins(70, 20);
    button->setPosition(ccp(center.x, center.y - 250));
    addChild(button);
    button->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloScene::playBtnCallback), CCControlEventTouchUpInside);

    return true;
}
bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

//获取可视区域尺寸大小
	CCSize mysize = CCDirector::sharedDirector()->getVisibleSize();
//获取可视区域的原点位置
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
//屏幕正中心位置
	CCPoint midPos = ccp(mysize.width/2, mysize.height/2);


//显示按钮状态的标签displayLabel
	displayLabel = CCLabelTTF::create("No Event", "Marker Felt", 32);
	displayLabel->setPosition( midPos + ccp(0, 100) );
	this->addChild(displayLabel);


//按钮中的背景精灵CCScale9Sprite
	CCScale9Sprite* bgNormal = CCScale9Sprite::create("btnNormal.png"); //正常背景
	CCScale9Sprite* bgHighlighted = CCScale9Sprite::create("btnHighlighted.png"); //高亮背景

//按钮中的标签CCLabelTTF
	CCLabelTTF* titleNormal = CCLabelTTF::create("Button is Normal !", "Marker Felt", 30);
	CCLabelTTF* titleHighlighted = CCLabelTTF::create("Button is Highlighted !", "Marker Felt", 30);


//创建按钮CCControlButton
	CCControlButton* btn = CCControlButton::create(titleNormal, bgNormal);
	btn->setPosition( midPos );
	this->addChild(btn);

//设置按钮高亮时的状态
	btn->setTitleLabelForState(titleHighlighted, CCControlStateHighlighted); //高亮标签
	btn->setTitleColorForState(ccRED, CCControlStateHighlighted); //红色
	btn->setBackgroundSpriteForState(bgHighlighted, CCControlStateHighlighted); //高亮背景

	//写了这句话,反而大小被固定了。没有按照label的大小进行自动伸展了
	//btn->setPreferredSize( CCSizeMake(120,40) );

//绑定事件,用于显示按钮状态
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown); //刚刚开始触摸按钮时
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragInsideAction), CCControlEventTouchDragInside);  //在内部拖动时(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragOutsideAction), CCControlEventTouchDragOutside); //在外部拖动时(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragEnterAction), CCControlEventTouchDragEnter);  //拖动刚进入内部时(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragExitAction), CCControlEventTouchDragExit); //拖动刚离开内部时(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpInsideAction), CCControlEventTouchUpInside); //在内部抬起手指(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpOutsideAction), CCControlEventTouchUpOutside); //在外部抬起手指(保持触摸状态下)
	btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchCancelAction), CCControlEventTouchCancel); //取消触点

	return true;
}
Exemple #7
0
void guankaScene::jumpBtn() {
    CCSize screenSize = CCDirector::sharedDirector()->getVisibleSize();
    
    CCLabelTTF* jumptext = CCLabelTTF::create("Jump!!", "Arial", 40);
    CCScale9Sprite* noDownbtn = CCScale9Sprite::create("button.png");
    CCScale9Sprite* downbtn = CCScale9Sprite::create("buttonDown.png");
    CCControlButton* Btnjump = CCControlButton::create(jumptext, noDownbtn);
    Btnjump->setPosition(ccp(screenSize.width-80, 50));
    Btnjump->setBackgroundSpriteForState(downbtn, extension::CCControlStateHighlighted);
    Btnjump->addTargetWithActionForControlEvents(this, cccontrol_selector(guankaScene::jumpEvent),CCControlEventTouchDown);
    this->addChild(Btnjump,1);
}
CCTableViewCell* RPGBattleMenu::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
    CCTableViewCell *cell = tableView->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
        cell->removeAllChildrenWithCleanup(true);
    
    if(dynamic_cast<RPGSkillBtnData*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了技能项
        RPGSkillBtnData *itemsData = (RPGSkillBtnData*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_MP)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    else if(dynamic_cast<RPGExistingItems*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了道具项
        
        RPGExistingItems *itemsData = (RPGExistingItems*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    
    return cell;
}
Exemple #9
0
void GamePan::refreshWorldPad()
{
	CCNode* pBaseNode = m_pCcbNode->getChildByTag(kTagGamePanWordPan);
	CCNode* tabNode = pBaseNode->getChildByTag(kTagGamePanWordPanTabBase);
	CCNode* itemNode = pBaseNode->getChildByTag(kTagGamePanWordPanItemBase);
	CCLabelTTF* itemTemp = dynamic_cast<CCLabelTTF*>(itemNode->getChildByTag(kTagGamePanWordPanItemTitle));
	CCControlButton* tabItem = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(kTagGamePanWordPanTabBaseItem));
	float itemWidth = tabItem->getContentSize().width+ITEM_SPACE;
	float itemHeight = tabItem->getContentSize().height+ITEM_SPACE;
	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = CCControlButton::create();
			Utils::copyCCControlButton(item,tabItem);
			item->setPosition(ccp(tabItem->getPositionX()+j*itemWidth,tabItem->getPositionY()-i*itemHeight));
			item->setTag(j+i*MAX_ROW);
			tabNode->addChild(item);

			CCLabelTTF* title = Utils::copyCCLabelTTF(itemTemp);
			title->setPosition(item->getPosition());
			title->setTag(j+i*MAX_ROW);
			itemNode->addChild(title);
			CCString* str = (CCString*)_wordList->randomObject();
			title->setString(str->getCString());
			_wordList->removeObject(str);
		}
	}

	for(int i =0;i<MAX_LINE;i++)
	{
		for(int j =0;j<MAX_ROW;j++)
		{
			CCControlButton* item = dynamic_cast<CCControlButton*>(tabNode->getChildByTag(j+i*MAX_ROW));
			XCheckBox* pCheckBox = XCheckBox::create(item);
			pCheckBox->setTag(item->getTag());
			pCheckBox->setToggle(false);
			pCheckBox->setTarget(this, cccontrol_selector(GamePan::wordSelectCallbackCCControl));
			tabNode->addChild(pCheckBox);
			item->removeFromParent();
		}
	}
	itemTemp->removeFromParent();
	tabItem->removeFromParent();
	refreshLetter();
}
bool CCControlButtonTest_HelloVariableSize::init()
{
    if (CCControlScene::init())
    {
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        
        // Defines an array of title to create buttons dynamically
        CCArray *stringArray = CCArray::create(
            ccs("Hello"),
            ccs("Variable"),
            ccs("Size"),
            ccs("!"),
            NULL);
        
        CCNode *layer = CCNode::create();
        addChild(layer, 1);
        
        double total_width = 0, height = 0;
        
        // For each title in the array
        CCObject* pObj = NULL;
        CCARRAY_FOREACH(stringArray, pObj)
        {
            CCString* title = (CCString*)pObj;
            // Creates a button with this string as title
            CCControlButton *button = standardButtonWithTitle(title->getCString());
            button->setPosition(ccp (total_width + button->getContentSize().width / 2, button->getContentSize().height / 2));
            layer->addChild(button);
            
            // Compute the size of the layer
            height = button->getContentSize().height;
            total_width += button->getContentSize().width;
        }

        layer->setAnchorPoint(ccp (0.5, 0.5));
        layer->setContentSize(CCSizeMake(total_width, height));
        layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
        
        // Add the black background
        CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png");
        background->setContentSize(CCSizeMake(total_width + 14, height + 14));
        background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f));
        addChild(background);
        return true;
    }
Exemple #11
0
bool TutorialLayer::init(){
    if (CCLayer::init()) {
        callback = NULL;
        target = NULL;
        
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCLayerColor *background = CCLayerColor::create(ccc4(0, 0, 0, 200), screenSize.width, screenSize.height);
        this->addChild(background);

        CCScale9Sprite *closeButtonSprite = Common::getCCScale9SpriteWithoutScale("CloseButton.png");
        CCControlButton *closeButton = CCControlButton::create(closeButtonSprite);
        closeButton->setPreferredSize(closeButtonSprite->getOriginalSize());
        closeButton->setContentSize(closeButtonSprite->getOriginalSize());
        closeButton->setPosition(ccp(screenSize.width*0.9, screenSize.height*0.9));
        closeButton->addTargetWithActionForControlEvents(this, cccontrol_selector(TutorialLayer::close), CCControlEventTouchUpInside);
        this->addChild(closeButton, CLOSE_BUTTON_Z);
        
        return true;
    }
    return false;
}
void QuestionLayer::displaySubViews()
{
    CCLOG("%f %f %f %f", this->getPositionX(), this->getPositionY(), this->getContentSize().width, this->getContentSize().height);

    CCArray* answer = questionObj->answerArray;

    int columns = 0;
    int rows = 0;
    float spaceX = 0;
    if (answer->count() <= 2) {
        //判断题2X1个
        columns = 2;
        rows = 1;
        spaceX = 80;
    } else if (answer->count() <= 3) {
        //3选1
        columns = 1;
        rows = 3;
        spaceX = 40;
    } else if (answer->count() <= 4) {
        //最多2x2个答案选项的
        columns = 2;
        rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
        spaceX = 60;
    } else if (answer->count() <= 9) {
        //最多3x3个答案选项
        columns = 3;
        rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
        spaceX = 40;
    } else if (answer->count() <= 16) {
        //最多4x4个答案选项
        columns = 4;
        rows = (answer->count()*1.0f/columns)>(answer->count()/columns)?(answer->count()/columns+1):(answer->count()/columns);
        spaceX = 20;
    }
    float spaceY = spaceX*(CCDirector::sharedDirector()->getWinSize().height/1334);

    //题目标题栏高度
    float topHeight = 190;
    CCLOG("%f %f", this->getContentSize().width, this->getContentSize().height);
    //
    float totalWidth = this->getContentSize().width;
    float cellWidth = (totalWidth-spaceX*(columns+1))/columns;
    float totalHeight = this->getContentSize().height-topHeight-50; //要减去答题头部区域
    float cellHeight = (totalHeight-spaceY*(rows+1))/rows;
    CCLOG("[%d %d]:%f %f", columns, rows, cellWidth, cellHeight);
    while (cellHeight > cellWidth) {
        spaceY += 10;
        cellHeight = (totalHeight-spaceY*(rows+1))/rows;
    }
    for (int i=0; i<answer->count(); i++) {
        //
        CCString* ans = (CCString *)(answer->objectAtIndex(i));
        CCLabelTTF* pLabel = CCLabelTTF::create(ans->getCString(), "Arial", 24, CCSizeMake(cellWidth, cellHeight), kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        CCControlButton* button = CCControlButton::create(pLabel, CCScale9Sprite::create("button_answer.png", CCRectMake(0, 0, 126, 70)));
        button->addTargetWithActionForControlEvents(this, cccontrol_selector(QuestionLayer::touchDownAction), CCControlEventTouchUpInside);
        button->setTag(i+1);
        button->setAnchorPoint(ccp(0.5f, 0.5f));
//        button->setPosition( ccp(-totalWidth/2+spaceX+(cellWidth+spaceX)*(i%columns)+cellWidth/2, -topHeight/2-totalHeight/2+spaceY+(cellHeight+spaceY)*(i/columns)+cellHeight/2) );
        button->setPosition( ccp(-totalWidth/2+spaceX+(cellWidth+spaceX)*(i%columns)+cellWidth/2, (totalHeight-topHeight)/2-spaceY-(cellHeight+spaceY)*(i/columns)-cellHeight/2) );
        CCLOG("button坐标:%f %f", button->getPositionX(), button->getPositionY());
        button->setPreferredSize(CCSize(cellWidth, cellHeight));
        this->addChild(button, 1);
    }
}
Exemple #13
0
bool QimiAlipayView::init()
{
    UIMaskLayerView* mask = UIMaskLayerView::create();
    this->addChild(mask);
    
    m_pButtonList = CCArray::create();
    m_pButtonList->retain();
    
    CCSize m_size = CCDirector::sharedDirector()->getWinSize();
    
    CCNode* container = CCNode::create();
    container->setTag(100);
    this->addChild(container);
    container->setPosition(ccp(m_size.width/2, m_size.height/2-45));
    
    CCNode* topCCNode = CCNode::create();
    topCCNode->setPosition(ccp(m_size.width/2, m_size.height-45));
    this->addChild(topCCNode);
    
    
    CCSprite* bgTop = CCSprite::create("bg_top.png");
    topCCNode->addChild(bgTop);
    bgTop->setPosition(ccp(0, 0));
    
    
    CCControlButton* backBtn = CCControlButton::create(CCScale9Sprite::create("btn_fanhui.png"));
    backBtn->setPreferredSize(CCSizeMake(101, 51));
    backBtn->setTouchPriority(-1000);
    topCCNode->addChild(backBtn);
    backBtn->setPosition(ccp(-163, 0));
    backBtn->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(QimiAlipayView::backOnClick),
                                                 CCControlEventTouchUpInside);
    
    
    CCControlButton* helpBtn = CCControlButton::create(CCScale9Sprite::create("btn_bangzhu.png"));
    helpBtn->setPreferredSize(CCSizeMake(93, 51));
    helpBtn->setTouchPriority(-1000);
    topCCNode->addChild(helpBtn);
    helpBtn->setPosition(ccp(163, 0));
    helpBtn->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(QimiAlipayView::qimiHelp),
                                                 CCControlEventTouchUpInside);
    
    CCLabelTTF* topText = CCLabelTTF::create("奇米支付中心", "Helvetica", 28);
    topCCNode->addChild(topText);
    topText->setColor(ccc3(104, 67, 2));
    topText->setPosition(ccp(0, 0));
    
    
    
    CCSprite* bg = CCSprite::create("bg_dabeijing_480x800.png");
    bg->setPosition(ccp(0, 0));
    container->addChild(bg);
    
    
    ////////////公共部分结束
    
    
    CCRect form = CCRectMake(0, 0, 40, 40);
    CCRect capInset = CCRectMake(10, 10, 10, 10);
    CCScale9Sprite* scale9Sprite = CCScale9Sprite::create("bg_40x40.png", form, capInset);
    scale9Sprite->setContentSize(CCSizeMake(445, 560));
    scale9Sprite->setPosition(ccp(0, 12));
    container->addChild(scale9Sprite);
    
//    CCNode* containerCCNode = CCNode::create();
//    container->addChild(containerCCNode);
//    containerCCNode->setPosition(ccp(6, 418));

    CCLabelTTF* txtTitle = CCLabelTTF::create("请选择充值金额(1元=10元宝)", "Helvetica", 26);
    container->addChild(txtTitle);
    txtTitle->setColor(ccc3(0, 0, 0));
    txtTitle->setPosition(ccp(-204, 259));
    txtTitle->setAnchorPoint(ccp(0, 0.5));
    
    
    CCControlButton* m_pBtnCongzhi = CCControlButton::create(CCScale9Sprite::create("btn_querenchongzhi.png"));

    m_pBtnCongzhi->setPreferredSize(CCSizeMake(248, 74));
    m_pBtnCongzhi->setTouchPriority(-1000);
    container->addChild(m_pBtnCongzhi);
    m_pBtnCongzhi->setPosition(ccp(0, -167));
    m_pBtnCongzhi->addTargetWithActionForControlEvents(this,
                                                         cccontrol_selector(QimiAlipayView::rechargeOnClick),
                                                         CCControlEventTouchUpInside);

    CCLabelTTF* label10 = CCLabelTTF::create("10元", "Helvetica", 18);
    label10->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn10Select = CCControlButton::create(label10, CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn10Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn10Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn10Select->setTouchPriority(-1000);
    container->addChild(m_pBtn10Select);
    m_pBtn10Select->setPosition(ccp(-104, 192));
    m_pBtn10Select->setTag(10);
    m_pBtn10Select->addTargetWithActionForControlEvents(this,
                                                    cccontrol_selector(QimiAlipayView::selected),
                                                    CCControlEventTouchUpInside);

   
    CCLabelTTF* label20 = CCLabelTTF::create("20元", "Helvetica", 18);
    label20->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn20Select = CCControlButton::create(label20, CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn20Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn20Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn20Select->setTouchPriority(-1000);
    container->addChild(m_pBtn20Select);
    m_pBtn20Select->setPosition(ccp(107, 192));
    m_pBtn20Select->setTag(20);
    m_pBtn20Select->addTargetWithActionForControlEvents(this,
                                                        cccontrol_selector(QimiAlipayView::selected),
                                                        CCControlEventTouchUpInside);

    
    CCLabelTTF* label30 = CCLabelTTF::create("30元", "Helvetica", 18);
    label30->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn30Select = CCControlButton::create(label30,CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn30Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn30Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn30Select->setTouchPriority(-1000);
    container->addChild(m_pBtn30Select);
    m_pBtn30Select->setPosition(ccp(-104, 136));
    m_pBtn30Select->setTag(30);
    m_pBtn30Select->addTargetWithActionForControlEvents(this,
                                                        cccontrol_selector(QimiAlipayView::selected),
                                                        CCControlEventTouchUpInside);
    
    
    CCLabelTTF* label50 = CCLabelTTF::create("50元", "Helvetica", 18);
    label50->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn50Select = CCControlButton::create(label50, CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn50Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn50Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn50Select->setTouchPriority(-1000);
    container->addChild(m_pBtn50Select);
    m_pBtn50Select->setPosition(ccp(107, 136));
    m_pBtn50Select->setTag(50);
    m_pBtn50Select->addTargetWithActionForControlEvents(this,
                                                        cccontrol_selector(QimiAlipayView::selected),
                                                        CCControlEventTouchUpInside);
    
    CCLabelTTF* label100 = CCLabelTTF::create("100元", "Helvetica", 18);
    label100->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn100Select = CCControlButton::create(label100,CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn100Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn100Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn100Select->setTouchPriority(-1000);
    container->addChild(m_pBtn100Select);
    m_pBtn100Select->setPosition(ccp(-104, 83));
    m_pBtn100Select->setTag(100);
    m_pBtn100Select->addTargetWithActionForControlEvents(this,
                                                        cccontrol_selector(QimiAlipayView::selected),
                                                        CCControlEventTouchUpInside);
    
    CCLabelTTF* label300 = CCLabelTTF::create("300元", "Helvetica", 18);
    label300->setColor(ccc3(0, 0, 0));
    CCControlButton* m_pBtn300Select = CCControlButton::create(label300, CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn300Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn300Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn300Select->setTouchPriority(-1000);
    container->addChild(m_pBtn300Select);
    m_pBtn300Select->setPosition(ccp(107, 82));
    m_pBtn300Select->setTag(300);
    m_pBtn300Select->addTargetWithActionForControlEvents(this,
                                                         cccontrol_selector(QimiAlipayView::selected),
                                                         CCControlEventTouchUpInside);
    
    CCLabelTTF* label500 = CCLabelTTF::create("500元", "Helvetica", 18);
    label500->setColor(ccc3(0, 0, 0));
    
    CCControlButton* m_pBtn500Select = CCControlButton::create(label500, CCScale9Sprite::create("bg_40x40.png"));
    m_pBtn500Select->setBackgroundSpriteForState(CCScale9Sprite::create("bg_seleceted.png"), CCControlStateDisabled);
    m_pBtn500Select->setPreferredSize(CCSizeMake(196, 47));
    m_pBtn500Select->setTouchPriority(-1000);
    container->addChild(m_pBtn500Select);
    m_pBtn500Select->setPosition(ccp(-104, 26));
    m_pBtn500Select->setTag(500);
    m_pBtn500Select->addTargetWithActionForControlEvents(this,
                                                         cccontrol_selector(QimiAlipayView::selected),
                                                         CCControlEventTouchUpInside);
    
    
    m_pButtonList->addObject(m_pBtn10Select);
    m_pButtonList->addObject(m_pBtn20Select);
    m_pButtonList->addObject(m_pBtn30Select);
    m_pButtonList->addObject(m_pBtn50Select);
    m_pButtonList->addObject(m_pBtn100Select);
    m_pButtonList->addObject(m_pBtn300Select);
    m_pButtonList->addObject(m_pBtn500Select);
    
    
    cocos2d::extension::CCScale9Sprite* m_pInputTxtBg = CCScale9Sprite::create("loginbg.png");
    CCSize editBoxSize = CCSizeMake(200, 45);
    m_pInputTxtBg->removeFromParentAndCleanup(false);
    m_pEditName = CCEditBox::create(editBoxSize, m_pInputTxtBg);
    m_pEditName->setPosition(ccp(-112, -35));
    m_pEditName->setFontColor(ccc3(255, 0, 0));
    m_pEditName->setMaxLength(20);
    m_pEditName->setReturnType(kKeyboardReturnTypeDone);
    m_pEditName->setTouchPriority(-1000);
    m_pEditName->setText("10");
    m_pEditName->setDelegate(this);
    container->addChild(m_pEditName);
    
    
    CCLabelTTF* yuan = CCLabelTTF::create("元", "Helvetica", 20);
    container->addChild(yuan);
    yuan->setColor(ccc3(0, 0, 0));
    yuan->setPosition(ccp(0, -40));
    yuan->setAnchorPoint(ccp(0, 0.5));
    
    CCLabelTTF* label01 = CCLabelTTF::create("您将充值", "Helvetica", 20);
    container->addChild(label01);
    label01->setColor(ccc3(0, 0, 0));
    label01->setPosition(ccp(-199, -83));
    label01->setAnchorPoint(ccp(0, 0.5));
    
    m_pMcashNumTxt = CCLabelTTF::create("1", "Helvetica", 20);
    m_pMcashNumTxt->setColor(ccc3(196, 9, 9));
    m_pMcashNumTxt->setPosition(ccp(-116, -84));
    m_pMcashNumTxt->setAnchorPoint(ccp(0, 0.5));
    container->addChild(m_pMcashNumTxt);
    
    m_pMcashNumLastTxt = CCLabelTTF::create("元宝", "Helvetica", 20);
    container->addChild(m_pMcashNumLastTxt);
    m_pMcashNumLastTxt->setColor(ccc3(0, 0, 0));
    m_pMcashNumLastTxt->setPosition(ccp(-84, -84));
    m_pMcashNumLastTxt->setAnchorPoint(ccp(0, 0.5));
    return true;
}
bool CPullMachHelpLayer::init()
{
	if (!CCLayer::init())
		return false;

	CCSize barDownSize;	//µ×Ãæ±ß¿ò³ß´ç
	CCSize barUpSize;	//ÉÏÃæ±ß¿ò³ß´ç
	CCSize infoBgSize;	//ÐÅÏ¢±³¾°³ß´ç
	CCSize infoViewSize;	//ÐÅÏ¢¿ÉÊӳߴç

	CCSprite * pSprite = NULL;
	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Down, pSprite))
	{
		barDownSize = pSprite->getContentSize();
		pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
		this->addChild(pSprite);
	}

	{
		float fHeight = this->getContentSize().height - 200;
		infoBgSize.setSize(barDownSize.width, (fHeight > 600) ? 600 : fHeight);
		CCLayerColor * bgLayer = CCLayerColor::create(ccc4(0, 24, 85, 255), infoBgSize.width, infoBgSize.height);
		bgLayer->setPosition(ccp(0, barDownSize.height));
		this->addChild(bgLayer);
	}

	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Up, pSprite))
	{
		barUpSize = pSprite->getContentSize();
		pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(ccp(0, barDownSize.height + infoBgSize.height));
		this->addChild(pSprite);
	}

	//Ìí¼Ó¹ö¶¯ÄÚÈÝ
	infoViewSize.setSize(infoBgSize.width - 20, infoBgSize.height);
	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Info, pSprite))
	{
		pSprite->setAnchorPoint(ccp(0.5f, 0.0f));
		pSprite->setPosition(ccp(infoViewSize.width / 2, 0));
	}

	CCLayerColor * layerColor = CCLayerColor::create(ccc4(0, 13, 32, 255), infoViewSize.width, pSprite->getContentSize().height);
	layerColor->setPosition(CCPointZero);
	layerColor->addChild(pSprite);

	m_pScroll = CCScrollView::create();
	m_pScroll->setViewSize(infoViewSize);
	m_pScroll->setPosition(ccp(10, barDownSize.height));
	m_pScroll->setDirection(kCCScrollViewDirectionVertical);
	m_pScroll->addChild(layerColor);
	m_pScroll->setContentSize(layerColor->getContentSize());
	m_pScroll->setContentOffset(m_pScroll->minContainerOffset());
	m_pScroll->setTouchPriority(kCCMenuHandlerPriority - 1);
	this->addChild(m_pScroll);

	this->setContentSize(CCSize(infoBgSize.width, barDownSize.height + barUpSize.height + infoBgSize.height));

	//Ìí¼Ó¹Ø±Õ°´Å¥
	CCControlButton* pCloseButton = m_pResManager->CreateControlButton(PullMach_Bt_Help_Close_N, PullMach_Bt_Help_Close_C);
	pCloseButton->setAnchorPoint(ccp(1, 1));
	pCloseButton->setPosition(getContentSize().width - 10, getContentSize().height - 4);
	pCloseButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CPullMachHelpLayer::OnTouchClose), CCControlEventTouchUpInside);
	pCloseButton->setScaleX(1.5f);
	this->addChild(pCloseButton);

	return true;
}
bool ControllerScene::init(){
    CCMenu *menu = CCMenu::create();
    menu->setPosition(CCPointZero);
    this->addChild(menu);
    
    CCLabelTTF *label = CCLabelTTF::create("CCTextFieldTTF", "Arial", 24);
    CCMenuItemLabel *item = CCMenuItemLabel::create(label, this, menu_selector(ControllerScene::menuItemClick1));
    item->setPosition(ccp(320, 1100));
    menu->addChild(item);
    
    label = CCLabelTTF::create("确定", "Arial", 24);
    m_btn = CCMenuItemLabel::create(label, this, menu_selector(ControllerScene::btnOk));
    m_btn->setPosition(ccp(400, 1050));
    menu->addChild(m_btn);
    
    m_texField = CCTextFieldTTF::textFieldWithPlaceHolder("input", CCSizeMake(200, 50), kCCTextAlignmentLeft, "Arial", 24);
    m_texField->setPosition(ccp(320, 1050));
    this->addChild(m_texField);
    m_texField->attachWithIME();
    
    m_name = CCLabelTTF::create("show info", "Arial", 24);
    m_name->setPosition(ccp(100, 1100));
    this->addChild(m_name);
    
    //CCControlButton label+s9
    label = CCLabelTTF::create("BUTTON", "Arial", 24);
    CCControlButton *btn = CCControlButton::create(label , CCScale9Sprite::create("start.png"));
    btn->setPreferredSize(CCSizeMake(228, 81));
    btn->setLabelAnchorPoint(ccp(0.5, 2));
    btn->setPosition(ccp(320, 1000));
    this->addChild(btn);
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ControllerScene::btnClick), CCControlEventTouchDown);
    
    //CCControlButton s9
    CCScale9Sprite *s9 = CCScale9Sprite::create("start.png");
    btn = CCControlButton::create(s9);
    btn->setPosition(ccp(320, 900));
    btn->setPreferredSize(CCSizeMake(228, 81));
    this->addChild(btn);
    
    //CCControlButton title
    btn = CCControlButton::create("CCControlButton", "Arial", 24);
    btn->setPosition(ccp(320, 800));
    this->addChild(btn);
    
    //s9
//    s9 = CCScale9Sprite::create("home.png");
//    s9->setPosition(ccp(100, 800));
//    this->addChild(s9);
    
    //CCControlColourPicker not useful
    CCControlColourPicker *cp = CCControlColourPicker::create();
    cp->setPosition(ccp(320, 750));
    this->addChild(cp);
    
    //CCControlPotentiometer
    CCControlPotentiometer *pot = CCControlPotentiometer::create("potentiometerTrack.png", "potentiometerProgress.png", "potentiometerButton.png");
    pot->setPosition(ccp(100, 750));
    this->addChild(pot);
    pot->setValue(90);
    
    //CCControlSlider
    CCControlSlider *slider = CCControlSlider::create("sliderTrack.png", "sliderProgress.png", "sliderThumb.png");
    slider->setPosition(ccp(150, 600));
    slider->setMinimumValue(0);
    slider->setMaximumValue(100);
    this->addChild(slider);
    slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ControllerScene::valueChanged), CCControlEventValueChanged);
    
    //CCControlStepper
    CCControlStepper *ste = CCControlStepper::create(CCSprite::create("stepper-minus.png"), CCSprite::create("stepper-plus.png"));
    ste->setPosition(ccp(320, 600));
    this->addChild(ste);
    
    //CCControlSwitch
    CCControlSwitch *swi = CCControlSwitch::create(CCSprite::create("switch-mask.png"), CCSprite::create("switch-on.png"), CCSprite::create("switch-off.png"), CCSprite::create("switch-thumb.png"), CCLabelTTF::create("on", "Arial", 24), CCLabelTTF::create("off", "Arial", 24));
    swi->setPosition(ccp(500, 600));
    this->addChild(swi);

    //
    CCEditBox *edi = CCEditBox::create(CCSizeMake(200, 50), CCScale9Sprite::create("start.png"));
    edi->setPosition(ccp(150, 500));
    this->addChild(edi);
    
    return true;
}
Exemple #16
0
bool HelloWorld::init()
{
    if ( !CCLayer::init())
    {
        return false;
    }
    //CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCNode* container = CCNode::create();
    this->addChild(container);
    container->setPosition(ccp(0, 80));
    
    QimiParamInfo* paramInfo = QimiParamInfo::create(21, 15, "7a92bba4670d479c5514720c1cf46aab", "pay");
    QimiPlatform::shareQimiPlatform()->setParamInfo(paramInfo);
    
    CCControlButton* backBtn0 = CCControlButton::create(CCLabelTTF::create("全屏WEBVIEW", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn0->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn0);
    backBtn0->setPosition(ccp(240, 590));
    backBtn0->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(HelloWorld::openWebURLFull),
                                                 CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn = CCControlButton::create(CCLabelTTF::create("QIMI登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn);
    backBtn->setPosition(ccp(240, 520));
    backBtn->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(HelloWorld::menuCloseCallback),
                                                 CCControlEventTouchUpInside);
    

    CCControlButton* backBtn3 = CCControlButton::create(CCLabelTTF::create("QIMI注册窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn3->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn3);
    backBtn3->setPosition(ccp(240, 450));
    backBtn3->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::reg),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn2 = CCControlButton::create(CCLabelTTF::create("QIMI直接登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn2->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn2);
    backBtn2->setPosition(ccp(240, 380));
    backBtn2->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::login),
                                                  CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn7 = CCControlButton::create(CCLabelTTF::create("QIMI充值中心", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn7->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn7);
    backBtn7->setPosition(ccp(240, 310));
    backBtn7->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::menuCloseCallback),
                                                  CCControlEventTouchUpInside);

    
    
    
    CCControlButton* backBtn4 = CCControlButton::create(CCLabelTTF::create("QIMI论坛", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn4->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn4);
    backBtn4->setPosition(ccp(240, 240));
    backBtn4->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::openWebURL),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn5 = CCControlButton::create(CCLabelTTF::create("忘记密码", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn5->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn5);
    backBtn5->setPosition(ccp(240, 160));
    backBtn5->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::forget),
                                                  CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn6 = CCControlButton::create(CCLabelTTF::create("退出QIMI", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn6->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn6);
    backBtn6->setPosition(ccp(240, 90));
    backBtn6->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::quit),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn9 = CCControlButton::create(CCLabelTTF::create("获取设备ID", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn9->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn9);
    backBtn9->setPosition(ccp(240, 20));
    backBtn9->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::getDivceId),
                                                  CCControlEventTouchUpInside);
    
    return true;
}
void RPGMapItemsMenuLayer::onButton(cocos2d::CCObject *pSender, CCControlEvent event)
{
    SimpleAudioEngine::sharedEngine()->playEffect("audio_effect_btn.wav");
    
    CCControlButton *itemBtn = (CCControlButton*)pSender;
    
    if(itemBtn->getTag() == kRPGMapItemsMenuLayerTagBtnDiscard)
    {
//        CCLog("丢弃道具");
        
        RPGResultsLogic::discardItems(this->m_db, this->m_selectedItems->m_dataId);
        
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg, true);
        this->getParent()->removeChildByTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer, true);
        this->getParent()->removeChildByTag(kRPGMapItemsMenuLayerTagBtnDiscard, true);
        this->setVisible(true);
        
        this->loadItemsData();
    }
    else
    {
        for (int i = 0; i < this->m_itemsList->count(); i++)
        {
            //判断选中道具
            RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(i);
            if(itemBtn->getTag() == itemsData->m_dataId)
            {
                this->m_selectedItems = itemsData;
                break;
            }
        }
        
        //因为动态获取地图的大小会导致了菜单层显示错位,所以定死了
        float width = 960;
        float height = 640;
        
        //临时背景
        CCTMXTiledMap *mainBg = CCTMXTiledMap::create(CCString::createWithFormat("map_menu3_%s.tmx", CCUserDefault::sharedUserDefault()->getStringForKey(GAME_STYLE).c_str())->getCString());
        mainBg->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, CCDirector::sharedDirector()->getWinSize().height / 2));
        mainBg->setAnchorPoint(ccp(0.5, 0.5));
        mainBg->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayerBg);
        this->getParent()->addChild(mainBg);
        
        CCString *title = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_choice"))->getCString(), this->m_selectedItems->m_name.c_str());
        RPGMapChoicePlayerMenuLayer *choicePlayer = RPGMapChoicePlayerMenuLayer::create(this->m_db, title, this, callfuncO_selector(RPGMapItemsMenuLayer::onChoicePlayer), width, height);
        choicePlayer->setTag(kRPGMapSceneLayerTagChoicePlayerMenuLayer);
        this->getParent()->addChild(choicePlayer);
        
        if(this->m_selectedItems->m_type != 3)
        {
//            CCLog("非道具不可以使用");
            choicePlayer->setHidden(true);
        }
        
        CCString *btnDiscardText = CCString::createWithFormat(((CCString*)this->m_stringList->objectForKey("menu_items_discard"))->getCString(), this->m_selectedItems->m_name.c_str());
        CCControlButton *btnDiscard = CCControlButton::create(btnDiscardText->getCString(), "Arial", 24);
        btnDiscard->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width / 2, 250));
        btnDiscard->setTag(kRPGMapItemsMenuLayerTagBtnDiscard);
        btnDiscard->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
        this->getParent()->addChild(btnDiscard);
        
        this->setVisible(false);
    }
    
}
Exemple #18
0
CTableSprite CStar97Game::CreateTableSprite()
{
	CTableSprite tableSprite;
	CCSize szBKSize;

	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Table, tableSprite.m_pTableBK))
	{
		szBKSize = tableSprite.m_pTableBK->getContentSize();
		tableSprite.m_pTableBK->setAnchorPoint(ccp(0.5f, 0.5f));
		tableSprite.m_pTableBK->setScale(1.4f);
	}
	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Table_P, tableSprite.m_pTableP))
	{
		szBKSize = tableSprite.m_pTableP->getContentSize();
		tableSprite.m_pTableP->setAnchorPoint(ccp(0.0f, 0.0f));
		tableSprite.m_pTableP->setPosition(CCPoint(0,0));
		tableSprite.m_pTableP->setZOrder(tableSprite.m_pTableBK->getZOrder()+1);
		tableSprite.m_pTableBK->addChild(tableSprite.m_pTableP);
	}
	//桌子编号
	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNum))
	{
		szBKSize = tableSprite.m_pTableBK->getContentSize();
		tableSprite.m_pTableNum->setAnchorPoint(ccp(0.5, 0.5));
		tableSprite.m_pTableNum->setPosition(ccp(120.f,240.f));
		//tableSprite.m_pTableNum->setScale(0.3f);
		if (NULL != tableSprite.m_pTableBK)
		{
			tableSprite.m_pTableBK->addChild(tableSprite.m_pTableNum);
		}
	}

	//游戏桌子编号
	if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, Star97_Room_Table_Num_Font, tableSprite.m_pTableNumP))
	{
		tableSprite.m_pTableNumP->setAnchorPoint(ccp(0.5, 0.5));
		tableSprite.m_pTableNumP->setPosition(ccp(120.f,240.f));
		//tableSprite.m_pTableNumP->setScale(0.3f);
		if (NULL != tableSprite.m_pTableP)
		{
			tableSprite.m_pTableP->addChild(tableSprite.m_pTableNumP);
		}
	}

	//座位
	for (int n = 0; n < 1; n++)
	{
		CSeatSprite seat;

		CCLabelTTF *titleButton = CCLabelTTF::create("", "Arial", 30);
		if (NULL == titleButton)
		{
			ERROR_CHECK;
			break;
		}
		titleButton->setColor(ccc3(159, 168, 176));

		CCScale9Sprite *backgroundButton = NULL;
		if (!m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundButton))
		{
			ERROR_CHECK;
			break;
		}

		CCControlButton* pButton = CMoveableButton::create(titleButton, backgroundButton);
		if (NULL == pButton)
		{
			ERROR_CHECK;
			break;
		}

		CCScale9Sprite *backgroundHighlightedButton = NULL;
		if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit, backgroundHighlightedButton))
		{
			pButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
		}

		CCScale9Sprite *backgroundDisibleButton = NULL;
		if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Room_Sit_D, backgroundDisibleButton))
		{
			pButton->setBackgroundSpriteForState(backgroundDisibleButton, CCControlStateDisabled);
		}

		pButton->setPosition(CCPoint(134.0f,105.0f));
		pButton->setAdjustBackgroundImage(false);
		//pButton->setZoomOnTouchDown(false);
		pButton->setTag(n);
		if (tableSprite.m_pTableP)
		{
			pButton->setZOrder(tableSprite.m_pTableP->getZOrder()+4);
		}

		tableSprite.m_pTableBK->addChild(pButton);
		seat.m_pSeat = pButton;

		//更新名称
		CCLabelTTF* pUserName = NULL; 

		if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Cfg, Star97_Font_Room_Sit_Name, pUserName))
		{

		}

		if (pUserName && tableSprite.m_pTableBK)
		{
			szBKSize = tableSprite.m_pTableBK->getContentSize();
			pUserName->setString("");
			pUserName->setPosition(ccp(szBKSize.width*0.5,0));
			pUserName->setHorizontalAlignment(kCCTextAlignmentCenter);
			pUserName->setVerticalAlignment(kCCVerticalTextAlignmentCenter);
			tableSprite.m_pTableBK->addChild(pUserName);
			seat.m_pNameLabel = pUserName;
		}

		tableSprite.m_vSeatSprites.push_back(seat);
	}

	return tableSprite;
}
bool CCLobbyView::init( CCNetworkLogic* network, const CCSize& mySize )
{
    if( CCLayer::init() )
    {
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        const CCPoint& center = ccpMult( ccpFromSize( mySize ), 0.5f );
        CCPoint position = CCPointZero;
        CCSize size = CCSizeZero;
        int length = 0;
        int fontSize = 0;
        
        this->setNetwork( network );
        
        CCSprite* s = CCSprite::create("Images/r1.png");
        s->retain();
        CCRect rect = CCRectZero;
        rect.size = s->getContentSize();
        s->release();
        
        fontSize = 12;
        CCLabelTTF* label = CCLabelTTF::create( "Connect", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        CCScale9Sprite* sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.4f );
        sprite->setScaleY( 0.8f );
        CCControlButton* button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::connectButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        position.x -= 100;
        button->setPosition( position );
        this->setConnectButton( button );
        
        label = CCLabelTTF::create( "Create Room", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.4f );
        sprite->setScaleY( 0.8f );
        button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::createGameButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        //position.x += 0;
        button->setPosition( position );
        this->setCreateGameButton( button );
        
        label = CCLabelTTF::create( "Random Room", "fonts/American Typewriter.ttf", fontSize );
        label->setColor( ccc3( 0, 0, 0 ) );
        sprite = CCScale9Sprite::create("Images/r1.png", rect, rect );
        sprite->setScaleX( 1.6f );
        sprite->setScaleY( 0.8f );
        button = CCControlButton::create( label, sprite );
        button->addTargetWithActionForControlEvents( this, cccontrol_selector( CCLobbyView::joinGameButtonCallback ), CCControlEventTouchUpInside);
        button->setPreferredSize( rect.size );
        position = center;
        position.y -= 136;
        position.x += 100;
        button->setPosition( position );
        this->setRandomGameButton( button );
        
        this->_lobbyViewDataSource = new CCLobbyViewDataSource( this );

        fontSize = 16;
        length = mySize.width;
        size = this->_lobbyViewDataSource->cellSizeForTable( NULL );
        size.height *= 3;
        CCTableView* table = CCTableView::create( this->_lobbyViewDataSource, size );
        table->setContentOffset( CCPointZero );
        table->setDirection(kCCScrollViewDirectionVertical);
        position = center;
        position.x -= size.width * 0.5f;
        position.y -= fontSize + ( size.height * 0.17f );
        table->setPosition( position );
        table->setDelegate( this );
        table->setVerticalFillOrder(kCCTableViewFillTopDown);
        this->setRoomTable( table );
        table->reloadData();
        
        fontSize = 16;
        label = CCLabelTTF::create("Running games:", "fonts/American Typewriter.ttf", fontSize,
                                                 winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        position = center;
        position.x -= size.width * 0.4f;
        position.y += size.height - ( fontSize * 0.5f );
        label->setPosition( position );
        //label->setAnchorPoint( CCPointZero );
        this->setRoomTableLabel( label );
        
        fontSize = 16;
        CCLabelTTF* console = CCLabelTTF::create("disconnected", "fonts/American Typewriter.ttf", fontSize,
                                             winSize, kCCTextAlignmentCenter, kCCVerticalTextAlignmentCenter);
        
            
        console->setColor( ccc3(255, 255, 255) );
        console->setContentSize(winSize);
        position = center;
        position.y += 100;
        console->setPosition( position );
        this->setConsole( console );
        
        label = CCLabelTTF::create( "localhost:5055", "fonts/American Typewriter.ttf", fontSize );
        position.y += fontSize;
        label->setPosition( position );
        this->setDisplayAddress( label );
        
        // top
        fontSize = 24;
        length = 19;
        size = CCSize( length * fontSize * 0.7f, fontSize * 1.7f );
        CCEditBox* edit = CCEditBox::create( size, CCScale9Sprite::create( "extensions/green_edit.png" ) );
        edit->setPosition( center );
        edit->setFontColor(ccBLACK);
        edit->setPlaceHolder("ip:port");
        edit->setMaxLength( 19 );
        edit->setReturnType(kKeyboardReturnTypeDone);
        edit->setDelegate(this);
        position.y -= fontSize * 2;
        edit->setPosition( position );
        this->setEditAddress( edit );
        
        //CCChatRoom* chatroom = CCChatRoom::create(this->getNetwork());
        //this->setChatRoom( chatroom );
        
        this->scheduleUpdate();

        return true;
    }
    
    return false;
}
Exemple #20
0
void GameSet::initContent()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCLayerColor *colorlayer = CCLayerColor::create(ccc4(0, 0, 0, 120));
    addChild(colorlayer);
    colorlayer->setPosition(ccp(-winSize.width/2, -winSize.height/2));
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("common/common.plist");
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("ui/gameSet/gameSet.plist");
    
    CCSprite *bg = CCSprite::create("common/commonBg_451_305.png");
    addChild(bg);
    
    CCSprite *titleBg = CCSprite::createWithSpriteFrameName("common_titleBg.png");
    bg->addChild(titleBg);
    titleBg->setPosition(ccp(bg->getContentSize().width/2 + 50, bg->getContentSize().height));
    
    CCLabelBMFont *title = CCLabelBMFont::create("设置", "font/font_uiTitle.fnt");
    titleBg->addChild(title);
    title->setPosition(ccp(titleBg->getContentSize().width/2 - 50, titleBg->getContentSize().height/2));
    
    CCScale9Sprite *frame = CCScale9Sprite::create("common/common_scale_1.png");
    frame->setPreferredSize(CCSizeMake(328, 150));
    frame->setAnchorPoint(ccp(0.5, 0.5));
    bg->addChild(frame);
    frame->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height/2 + 40));

    
//    CCSprite *title = CCSprite::createWithSpriteFrameName("set_title.png");
//    bg->addChild(title);
//    title->setPosition(ccp(bg->getContentSize().width/2, bg->getContentSize().height - 20));
    
    
    CCControlButton *closeBtn = INSTANCE(ButtonUtils)->createButton("common_backBtn.png", CCSizeMake(75, 81), "");
    bg->addChild(closeBtn);
    closeBtn->setPosition(ccp(bg->getContentSize().width - 20, bg->getContentSize().height - 20));
    closeBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::close), CCControlEventTouchUpInside);
    
    CCLabelBMFont *musicLabel = CCLabelBMFont::create("音乐", "font/font_common.fnt");
    bg->addChild(musicLabel);
    musicLabel->setPosition(ccp(115, 235));
    
    CCControlSlider *musicSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    musicSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    musicSlider->setMinimumValue(0.0f); // Sets the min value of range
    musicSlider->setMaximumValue(1.0f); // Sets the max value of range
    musicSlider->setTag(1);
    musicSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::musicCallBack), CCControlEventValueChanged);
    musicSlider->setPosition(ccp(260, 250));
    musicSlider->setTouchPriority(0);
    float musicVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_musicVolume, 0.5);
    musicSlider->setValue(musicVolume);
    bg->addChild(musicSlider);
    
    CCLabelBMFont *soundLabel = CCLabelBMFont::create("音效", "font/font_common.fnt");
    bg->addChild(soundLabel);
    soundLabel->setPosition(ccp(115, 185));
    
    CCControlSlider *soundSlider = CCControlSlider::create(CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barFrame.png"), CCSprite::createWithSpriteFrameName("set_barBtn.png"));
    soundSlider->setAnchorPoint(ccp(0.5f, 1.0f));
    soundSlider->setMinimumValue(0.0f); // Sets the min value of range
    soundSlider->setMaximumValue(1.0f); // Sets the max value of range
    soundSlider->setTag(1);
    soundSlider->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::soundCallBack), CCControlEventValueChanged);
    soundSlider->setPosition(ccp(260, 200));
    soundSlider->setTouchPriority(0);
    float soundVolume = CCUserDefault::sharedUserDefault()->getFloatForKey(GameSet_soundVolume, 0.5);
    soundSlider->setValue(soundVolume);
    bg->addChild(soundSlider);
    
    
    CCControlButton *btn1 = INSTANCE(ButtonUtils)->createButton("set_guide.png", CCSizeMake(84, 87), "");
    
    CCControlButton *btn3 = INSTANCE(ButtonUtils)->createButton("set_contact.png", CCSizeMake(83, 84), "");
    CCControlButton *btn4 = INSTANCE(ButtonUtils)->createButton("set_develep.png", CCSizeMake(83, 92), "");
    
    bg->addChild(btn1);
    
    bg->addChild(btn3);
    bg->addChild(btn4);
    
    if(showHelp){
        wikiBtn = INSTANCE(ButtonUtils)->createButton("set_wiki.png", CCSizeMake(87, 89), "");
        bg->addChild(wikiBtn);
        btn1->setPosition(ccp(80, 50));
        wikiBtn->setPosition(ccp(180, 50));
        btn3->setPosition(ccp(280, 50));
        btn4->setPosition(ccp(380, 50));
        
        wikiBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn2Handler), CCControlEventTouchUpInside);
    }else{
        btn1->setPosition(ccp(80, 50));
        btn3->setPosition(ccp(230, 50));
        btn4->setPosition(ccp(380, 50));
    }
    
    btn1->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn1Handler), CCControlEventTouchUpInside);
    btn3->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn3Handler), CCControlEventTouchUpInside);
    btn4->addTargetWithActionForControlEvents(this, cccontrol_selector(GameSet::btn4Handler), CCControlEventTouchUpInside);
    
    
    
}