Exemple #1
0
NS_CC_BEGIN

#pragma CATableView

CATableView::CATableView()
:m_pTableHeaderView(NULL)
,m_pTableFooterView(NULL)
,m_pTablePullDownView(NULL)
,m_pTablePullUpView(NULL)
,m_separatorColor(ccc4(127, 127, 127, 255))
,m_nTableHeaderHeight(0)
,m_nTableFooterHeight(0)
,m_nTablePullViewHeight(0)
,m_pTableViewDataSource(NULL)
,m_pTableViewDelegate(NULL)
,m_pBackGroundView(NULL)
,m_pHighlightedTableCells(NULL)
,m_bAllowsSelection(false)
,m_bAllowsMultipleSelection(false)
{
    m_pCellDict = new CCDictionary();
}
Exemple #2
0
void GameScene::initWithMapInformation(int leve, int status, int life)
{
    // 开始音乐
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("start.aif");
    
    // 创建一个颜色层
    CCLayerColor *backColor = CCLayerColor::create(ccc4(192, 192, 192, 255));
    this->addChild(backColor, 1);
                                                
    // 精灵帧类,提高效率
    CCSpriteFrameCache *frameCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    frameCache->addSpriteFramesWithFile("images/images.plist");
    
    // 场景内一些精灵的创建
    CCSize wSize = CCDirector::sharedDirector()->getWinSize();
    
    CCSprite *ipLife = CCSprite::createWithSpriteFrameName("IP.png");
    ipLife->setPosition(ccp(30, wSize.height - 50));
    ipLife->setScale(1.0f);
    this->addChild(ipLife, 1);
    CCSprite *ipLifeIock = CCSprite::createWithSpriteFrameName("p1.png");
    ipLifeIock->setPosition(ccp(20, wSize.height - 70));
    ipLifeIock->setScale(0.5f);
    this->addChild(ipLifeIock, 1);
    
    this->showLife(life);
    
    CCSprite *flag = CCSprite::createWithSpriteFrameName("flag.png");
    flag->setPosition(ccp(wSize.width - 50, wSize.height - 200));
    flag->setScale(1.0f);
    this->addChild(flag, 1);
    
    this->showLeve(leve);
    
    _mapLayer = MapLayer::create();
    _mapLayer->initWithMap(leve, status, life);
    _mapLayer->setPosition(ccp(wSize.width/6, 0));
    this->addChild(_mapLayer, 1);
}
Exemple #3
0
void DirectKey::OnTouchDown(KeyDirect type)
{
	if (m_touchDown) return;
	
	m_touchDown = true;
	
	m_keyDirect = type;
	
	UpdateDownPicture();
	
	DealKey(m_keyDirect);
	
	m_timer->SetTimer(this, 1, 1.0f / 60.0f);
	
	if (AutoPathTipObj.IsWorking())
		AutoPathTipObj.Stop();
	
	if (m_picCenterNormal) 
	{
		m_picCenterNormal->SetColor(ccc4(255, 255, 255, 255));
	}
}
bool MDPauseMenu::init(MDPauseMenuInterfaz* target)
{
    if (CCLayerColor::initWithColor(ccc4(0, 0, 0, 200)) )
    {
        mTarget = target;
        
        Size visibleSize  = Director::getInstance()->getVisibleSize();
        
        // Menu items
        MenuItemFont *btResume = MenuItemFont::create("Resume",
                                                          this,
                                                          menu_selector(MDPauseMenu::resumeGame));
        btResume->setColor(ccc3(255, 255, 255));
        btResume->setAnchorPoint(ccp(0.5, 1));
		btResume->setPosition(ccp(0, 0));
        
        MenuItemFont *btRetry = MenuItemFont::create("Retry",
                                                          this,
                                                          menu_selector(MDPauseMenu::retryGame));
        btRetry->setColor(ccc3(255, 255, 255));
		btRetry->setAnchorPoint(ccp(0.5, 1));
		btRetry->setPosition(ccp(0, btResume->getPosition().y - btResume->getContentSize().height - MENU_ITEMS_SPACING));

        MenuItemFont *btExit = MenuItemFont::create("Exit",
                                                          this,
                                                          menu_selector(MDPauseMenu::quitGame));
        btExit->setColor(ccc3(255, 255, 255));
		btExit->setAnchorPoint(ccp(0.5, 1));
		btExit->setPosition(ccp(0, btRetry->getPosition().y - btRetry->getContentSize().height - MENU_ITEMS_SPACING));
        
        // Menu
        Menu *menu = Menu::create(btResume, btRetry, btExit, NULL);
		menu->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
        addChild(menu);
        
        return true;
    }
    return false;
}
void ExtensionsTest::viewDidLoad()
{
	this->getNavigationBarItem()->setTitle("Json analysis");
	size = this->getView()->getBounds().size;

	table = CATableView::createWithCenter(CADipRect(size.width*0.5, size.height*0.5, size.width, size.height));
	table->setTableViewDataSource(this);
	table->setTableViewDelegate(this);
	table->setAllowsSelection(true);
	table->setSeparatorViewHeight(1);
	this->getView()->addSubview(table);

	CADipSize nSize = this->getNavigationController()->getNavigationBar()->getBounds().size;
	next = CAButton::createWithCenter(CADipRect(nSize.width*0.905, nSize.height*0.5, nSize.height*0.9, nSize.height*0.8), CAButtonTypeCustom);
	next->setTag(1000);
	next->setImageForState(CAControlStateNormal, CAImage::create("source_material/btn_right_white.png"));
	next->setImageColorForState(CAControlStateHighlighted, ccc4(0, 255, 200, 255));
	next->addTarget(this, CAControl_selector(ExtensionsTest::nextViewController), CAControlEventTouchUpInSide);
	this->getNavigationController()->getNavigationBar()->addSubview(next);

	loadJsonData();
}
Exemple #6
0
void DramaRightChat::Initialization()
{
	DramaChatLayer::Initialization();

	CCSize winsize = CCDirector::sharedDirector()->getWinSizeInPixels();

	SetFrameRect(CCRectMake(0, 0, winsize.width, winsize.height));
	
	//ÉèÖñ³¾°
	NDUILayer *backlayer = new NDUILayer;
	backlayer->Initialization();
	backlayer->SetFrameRect(CCRectMake(0, 0, winsize.width*0.9, winsize.height*0.3));
	backlayer->SetBackgroundColor(ccc4(0,0,0,60));
	AddChild(backlayer, -1);

	NDUILoad uiload;
	uiload.Load("dramaini/DLG_R.ini", this, NULL);

	SetFigureTag(ID_DLG_R_CTRL_PICTURE_PLAYER);
	SetTitleTag(ID_DLG_R_CTRL_TEXT_TITAL);
	SetContentTag(ID_DLG_R_CTRL_TEXT_DLG);
}
void CommonProgressHUD::showHUD(CCObject* sender) {
    CCProgressHUD* hud = CCProgressHUD::show("Loading...");
    hud->setPanelColor(ccc4(255, 0, 0, 200));
    
    runAction(CCSequence::create(CCDelayTime::create(2),
                                 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeMessage)),
								 CCDelayTime::create(2),
                                 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeRichMessage)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changePanelColor)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeDimColor)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::forceSquare)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::changeIcon)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::beforeHide)),
								 CCDelayTime::create(2),
								 CCCallFunc::create(this, callfunc_selector(CommonProgressHUD::hide)),
                                 NULL));
}
void HallPage::onSendMsgClicked()
{
    if(m_sendMsgDialog != 0){
        m_sendMsgDialog->destroy();
        m_sendMsgDialog = 0;
    }
    CCNode *root = this->getParent();
    while(root->getParent())
        root = root->getParent();
    if(m_sendMsgDialog == 0){
        m_sendMsgDialog = new SendMsgDialog(root,ccc4(0,0,0,128));
        m_sendMsgDialog->setCloseCB(this,callfuncND_selector(HallPage::onSendMsgCloseClicked));
        m_sendMsgDialog->setSendCB(this,callfuncND_selector(HallPage::onSendMsgSendClicked));
        m_sendMsgDialog->setInitShowPage(true);
        m_sendMsgDialog->setInitPage(true,false);
        std::string name = m_headNick;
        if(name.empty())
            mailToNickName(m_headMail,name);
        m_sendMsgDialog->setRecInfo(m_headId,name,"");
        m_sendMsgDialog->exec();
    }
}
Exemple #9
0
bool GameOver::init(){
    if(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 150))){
        return false;
    }
    setTouchEnabled(true);
   
    
   CCSize size= CCDirector::sharedDirector()->getWinSize();
    label1=CCLabelTTF::create("+10", "黑体", 35);
    label1->setPosition(ccp(size.width/2, size.height/2-25));
    this->addChild(label1,2);
    CCSprite *bg= CCSprite::create("over_bg.png");
    bg->setPosition(ccp(size.width/2, size.height/2));
    this->addChild(bg,0);
    CCMenuItemImage * item=CCMenuItemImage::create("back_up.png", "back_down.png", this, menu_selector(GameOver::goback));
    item->setPosition(ccp(0, -200));
    menu=CCMenu::create(item,NULL);
    this->addChild(menu,1);
    
    return true;
    
}
void SessionsViewController::initMsgTableView()
{
    if (m_msg.empty())
    {
        showAlert();
        return;
    }
    if (m_msgTableView != NULL)
    {
        this->getView()->removeSubview(m_msgTableView);
        m_msgTableView = NULL;
    }
    
    m_msgTableView = CATableView::createWithFrame(DRect(0, _px(120), m_winSize.width, m_winSize.height - _px(120)));
    m_msgTableView->setTableViewDataSource(this);
    m_msgTableView->setTableViewDelegate(this);
    m_msgTableView->setScrollViewDelegate(this);
    m_msgTableView->setAllowsSelection(true);
    m_msgTableView->setSeparatorColor(ccc4(200, 200, 200, 80));
    //m_msgTableView->setSeparatorViewHeight(_px(2));
    this->getView()->addSubview(m_msgTableView);
}
Exemple #11
0
ccColor4B CUIChatText::GetColorByTag(int tag)
{
	switch(tag){
		case QUALITY_WHITE:
			return ccc4(255,255,255,255);
		case QUALITY_GREEN:
			return ccc4(0,255,0,255);
		case QUALITY_BLUE:
			return ccc4(0,0,255,255);
		case QUALITY_PURPLE:
			return ccc4(167,87,168,255);
		case QUALITY_GOLDEN:
			return ccc4(255,215,0,255);
		default:
			return ccc4(255,255,255,255);
	}
}
Exemple #12
0
// on "init" you need to initialize your instance
bool Bug914Layer::init()
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super" return value
    if (BugsTestBaseLayer::init())
    {
        setTouchEnabled(true);
        // ask director the the window size
        CCSize size = CCDirector::sharedDirector()->getWinSize();
        CCLayerColor *layer;
        for( int i=0;i < 5;i++)
        {
            layer = CCLayerColor::create(ccc4(i*20, i*20, i*20,255));
            layer->setContentSize(CCSizeMake(i*100, i*100));
            layer->setPosition(ccp(size.width/2, size.height/2));
            layer->setAnchorPoint(ccp(0.5f, 0.5f));
            layer->setIsRelativeAnchorPoint(true);
            addChild(layer, -1-i);
        }

        // create and initialize a Label
        CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64);
        CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart));

        CCMenu *menu = CCMenu::create(item1, NULL);
        menu->alignItemsVertically();
        menu->setPosition(ccp(size.width/2, 100));
        addChild(menu);

        // position the label on the center of the screen
        label->setPosition(ccp( size.width /2 , size.height/2 ));

        // add the label as a child to this Layer
        addChild(label);
        return true;
    }
    return false;
}
Exemple #13
0
bool RootWindow::init()
{
    if (!CAWindow::init())
    {
        return false;
    }
    this->setColor(ccc4(87, 154, 244, 255));

    DMTabBarController* tabBarController = new DMTabBarController();
    tabBarController->initWithTabBarController();

    CANavigationController* nav = new CANavigationController();
    nav->initWithRootViewController(tabBarController);
    nav->setNavigationBarHidden(true, false);

    DMClassificationViewController* classificationViewController = DMClassificationViewController::create();

    CADrawerController* drawer = new CADrawerController();
    drawer->initWithController(classificationViewController, nav, this->getBounds().size.width * 5/6.0f);
    drawer->setBackgroundView(CAView::createWithColor(CAColor_black));
    tabBarController->release();
    nav->release();

    CCRect rect = this->getBounds();
    rect.size.height /= 2;
    rect.origin.y = rect.size.height;
    drawer->getBackgroundView()->addSubview(CAView::createWithFrame(rect));

    this->setRootViewController(drawer);
    drawer->release();

    m_pRootTabBarController = tabBarController;
    m_pRootNavigationController = nav;
    m_pRootDrawerController = drawer;


    return true;
}
Exemple #14
0
CATableViewCell* FirstViewController::tableCellAtIndex(CATableView* table, const CCSize& cellSize, unsigned int section, unsigned int row)
{
	CADipSize _size = cellSize;
	CATableViewCell* cell = table->dequeueReusableCellWithIdentifier("CrossApp");
	if (cell == NULL)
	{
		cell = CATableViewCell::create("CrossApp");
		CALabel* test = CALabel::createWithCenter(CADipRect(_size.width*0.5,
												_size.height*0.5,
												_size.width*0.8,
												_size.height));
		test->setColor(ccc4(51, 204, 255, 255));
		test->setTextAlignment(CATextAlignmentCenter);
		test->setVerticalTextAlignmet(CAVerticalTextAlignmentCenter);
		test->setFontSize(_px(40));
		test->setTag(100);
		cell->addSubview(test);
	}
	CALabel* test = (CALabel*)cell->getSubviewByTag(100);
	test->setText(testList.at(row));
	
	return cell;
}
void ActivityIndicatorViewTest::viewDidLoad()
{
	size = this->getView()->getBounds().size;
	this->getView()->setColor(ccc4(58,210,129,255));

	whiteLarge = CAActivityIndicatorView::createWithCenter(CCRect(size.width*0.5, size.height*0.25,
		size.width*0.2, size.width*0.2));
	whiteLarge->setStyle(CAActivityIndicatorViewStyleWhiteLarge);
	this->getView()->addSubview(whiteLarge);
	whiteLarge->startAnimating();

	white = CAActivityIndicatorView::createWithCenter(CCRect(size.width*0.5, size.height*0.5, 
		size.width*0.2,size.width*0.2));
	white->setStyle(CAActivityIndicatorViewStyleWhite);
	this->getView()->addSubview(white);
	white->startAnimating();

	gray = CAActivityIndicatorView::createWithCenter(CCRect(size.width*0.5, size.height*0.75,
		size.width*0.2, size.width*0.2));
	gray->setStyle(CAActivityIndicatorViewStyleGray);
	this->getView()->addSubview(gray);
	gray->startAnimating();
}
Exemple #16
0
void GameScene::showPauseView()
{
    m_Paused = true;

    if (m_pPauseLayer == NULL)
    {
        m_pPauseLayer = LGLayerColor::create(ccc4(0, 0, 0, 0));
        m_pPauseLayer->retain();
        m_pPauseLayer->setTouchMode(kCCTouchesOneByOne);
        m_pPauseLayer->setTouchEnabled(true);
        m_pPauseLayer->setZOrder(3);

        CCSprite *pTitle = CCSprite::create("title_pause.png");
        pTitle->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width / 2 , m_VisibleOrigin.y + m_VisibleSize.height * 0.67375f));
        m_pPauseLayer->addChild(pTitle);

        CCMenuItemImage *pContinue = LGMenuItemImage::create("play.png", NULL, this, menu_selector(GameScene::continueCallback));
        CCMenuItemImage *pMenu = LGMenuItemImage::create("menu.png", NULL, this, menu_selector(GameScene::menuCallback));

        pContinue->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.26666667f, m_VisibleOrigin.y + m_VisibleSize.height * 0.41125));
        pMenu->setPosition(ccp(m_VisibleOrigin.x + m_VisibleSize.width * 0.73333333f, pContinue->getPositionY()));

        CCMenu *pCCMenu = CCMenu::create(pContinue, pMenu, NULL);
        pCCMenu->setAnchorPoint(CCPointZero);
        pCCMenu->setPosition(CCPointZero);
        m_pPauseLayer->addChild(pCCMenu);
    }

    if (m_pPauseLayer && m_pPauseLayer->getParent() == NULL)
    {
        getParent()->addChild(m_pPauseLayer);
        CC_SAFE_RELEASE_NULL(m_CurrentLayer);
        m_CurrentLayer = m_pPauseLayer;
        m_CurrentLayer->retain();
        onShowOverlay(true);
    }
}
Exemple #17
0
void CCSquirmAnimNode::rebuildVertices()
{
	if(m_vertices_dirty)
	{
		memset(&m_sQuad, 0, sizeof(m_sQuad));
		int w = m_obContentSize.width;
		int h = m_obContentSize.height;
		int texture_w = m_pobTexture->getPixelsWide();
		int texture_h = m_pobTexture->getPixelsHigh();
		float max_u0 = (float)w / (float)texture_w / m_texture_horz_scale;
		float max_u1 = max_u0 / m_mask_horz_scale;

		ccColor4B clr = ccc4(m_color.r, m_color.g, m_color.b, m_opacity);

		m_sQuad.bl.vertices = vertex3(0.0f, 0.0f, 0.0f);
		m_sQuad.bl.colors = clr;
		m_sQuad.bl.texCoords = tex2(0.0f, 1.0f);
		m_sQuad.bl.texCoords1 = tex2(m_mask_left_edge, 1.0f);

		m_sQuad.br.vertices = vertex3(m_obContentSize.width, 0.0f, 0.0f);
		m_sQuad.br.colors = clr;
		m_sQuad.br.texCoords = tex2(max_u0, 1.0f);
		m_sQuad.br.texCoords1 = tex2(m_mask_left_edge + max_u1, 1.0f);

		m_sQuad.tl.vertices = vertex3(0.0f, m_obContentSize.height, 0.0f);
		m_sQuad.tl.colors = clr;
		m_sQuad.tl.texCoords = tex2(0.0f, 0.0f);
		m_sQuad.tl.texCoords1 = tex2(m_mask_left_edge, 0.0f);

		m_sQuad.tr.vertices = vertex3(m_obContentSize.width, m_obContentSize.height, 0.0f);
		m_sQuad.tr.colors = clr;
		m_sQuad.tr.texCoords = tex2(max_u0, 0.0f);
		m_sQuad.tr.texCoords1 = tex2(m_mask_left_edge + max_u1, 0.0f);

		m_vertices_dirty = false;
	}
}
Exemple #18
0
// on "init" you need to initialize your instance
bool LevelGameScene::init()
{
	if ( !CCLayerColor::initWithColor( ccc4(100, 100, 100, 255) ) )
	{
		return false;
	}

	CCSize vs = CCDirector::sharedDirector()->getVisibleSize();
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	// Fondo con la textura de madera
	ccTexParams tp = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
	CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("purty_wood.png");
				 texture->setTexParameters(&tp);
	CCSprite* background = CCSprite::createWithTexture(texture, CCRectMake(0, 0, vs.width, vs.height));
			  background->setPosition( ccp( vs.width/2, vs.height/2 ) );

	this->addChild(background, 1);

	CCMenuItem* level1 = CCMenuItemImage::create("btn_level_1.png", "btn_level_1_h.png", this, menu_selector(LevelGameScene::level1Callback));
				level1->setPosition(ccp(vs.width/2 - 275, vs.height/2));

	CCMenuItem* level2 = CCMenuItemImage::create("btn_level_2.png", "btn_level_2_h.png", this, menu_selector(LevelGameScene::level2Callback));
				level2->setPosition(ccp(vs.width/2, vs.height/2));

	CCMenuItem* level3 = CCMenuItemImage::create("btn_level_3.png", "btn_level_3_h.png", this, menu_selector(LevelGameScene::level3Callback));
				level3->setPosition(ccp(vs.width/2 + 275, vs.height/2));

	CCMenu* menu = CCMenu::create(level1, level2, level3, NULL);
			menu->setPosition(ccp(0,0));

	this->addChild(menu, 5);

    this->setTouchEnabled(true);

    return true;
}
Exemple #19
0
bool PromptBox::init()
{
	if (!CCLayer::init())
		return false;

	//窗口大小
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	//当前层的位置
	CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	CCLayerColor* layercolor = CCLayerColor::create(ccc4(0,0,0,150),800,480) ;
	addChild(layercolor) ;

	ui = TouchGroup::create();
	ui->addWidget(GUIReader::shareReader()->widgetFromJsonFile("UI/GameMainMenu_1/promptBox.ExportJson"));

	ui->setScale(0.8);
	addChild(ui, 2);

	registerTouchEvent(ui, "prompt_cancel", this, PromptBox::buttonClicked);
	registerTouchEvent(ui, "prompt_confirm", this, PromptBox::buttonClicked);

	return true;
}
bool CAScrollView::initWithFrame(const cocos2d::CCRect &rect)
{
    if (!CAView::initWithFrame(rect))
    {
        return false;
    }

    this->setDisplayRange(false);
    
    m_pContainer = CAView::createWithFrame(this->getBounds(), ccc4(255, 255, 255, 0));
    m_pChildInThis->addObject(m_pContainer);
    this->addSubview(m_pContainer);
    
    m_pIndicatorHorizontal = CAIndicator::createWithFrame(CCRect(12, rect.size.height - 12, rect.size.width - 24, 10), CAIndicator::CAIndicatorTypeHorizontal);
    m_pChildInThis->addObject(m_pIndicatorHorizontal);
    this->insertSubview(m_pIndicatorHorizontal, 1);
    
    m_pIndicatorVertical = CAIndicator::createWithFrame(CCRect(rect.size.width - 12, 12, 10, rect.size.height - 24), CAIndicator::CAIndicatorTypeVertical);
    m_pChildInThis->addObject(m_pIndicatorVertical);
    this->insertSubview(m_pIndicatorVertical, 1);
    
    
    return true;
}
Exemple #21
0
NDUILabel* StageUI_AutoPatch::getFileCountLabel(float width /*= 300.f*/,
												float height /*= 100.f*/, float bottomPadding /*= 100.f*/)
{
	if (!m_pkFileCountLabel)
	{
		//新建控件
		m_pkFileCountLabel = new NDUILabel();
		m_pkFileCountLabel->Initialization();
		m_pkFileCountLabel->SetFontSize(25);
		m_pkFileCountLabel->SetFontColor(ccc4(0, 0xff, 0, 0xff));
		m_pkFileCountLabel->SetFrameRectFull();

		float fBottomPadding = 0.0f;

		//计算位置
		CCSize kWinSizePix = CCDirector::sharedDirector()->getWinSizeInPixels();
		float widgetWidth = width * RESOURCE_SCALE_960;
		float widgetHeight = height * RESOURCE_SCALE_960;
		fBottomPadding = fBottomPadding * RESOURCE_SCALE_960;
		float widgetX = 0.5f * (kWinSizePix.width - widgetWidth);
		float widgetY = kWinSizePix.height - fBottomPadding - widgetHeight * 3;
		m_pkFileCountLabel->SetFrameRect(
			CCRectMake(widgetX, widgetY, widgetWidth, widgetHeight));

		//加入UIRoot
		extern NDUIRoot* GetUIRoot();
		NDUIRoot* pkUIRoot = GetUIRoot();

		if (m_pkUILayer)
		{
			m_pkUILayer->AddChild(m_pkFileCountLabel, 1);
		}
	}

	return m_pkFileCountLabel;
}
Exemple #22
0
bool WaitingNode::init()
{
	if (!CustomNode::init())
	{
		return false;
	}

	LayerColor* pBackground = LayerColor::create(ccc4(7, 25, 44, 150));
	pBackground->setContentSize(CCSizeMake(640.0f, 960.0f));
	this->addChild(pBackground);
	this->setContentSize(pBackground->getContentSize());

	Sprite* pBackgroundBoard = Sprite::create("popup/panel_popup_waiting.png");
	pBackgroundBoard->setPosition(Point(320.0f, 480.0f));
	pBackgroundBoard->setScaleY(0.7f);
	this->addChild(pBackgroundBoard);

	m_pLabelTitle = LabelBMFont::create(m_sTitle, "fonts/font_title-popup.fnt", 410.0f, TextHAlignment::CENTER);
	m_pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f));
	m_pLabelTitle->setPosition(Point(320.0f, 485.0f));
	this->addChild(m_pLabelTitle);

	return true;
}
//------------------------------------------------------------------
//
// LabelTTFTest
//
//------------------------------------------------------------------
LabelTTFTest::LabelTTFTest()
{
    CCSize blockSize = CCSizeMake(200, 160);
    CCSize s = CCDirector::sharedDirector()->getWinSize();

    CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height);
    colorLayer->setAnchorPoint(ccp(0,0));
    colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2));

    this->addChild(colorLayer);

    CCMenuItemFont::setFontSize(30);
    CCMenu *menu = CCMenu::create(
        CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)),
        CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)),
        CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(50, s.height / 2 - 20));
    this->addChild(menu);

    menu = CCMenu::create(
        CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)),
        CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)),
        CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)),
        NULL);
    menu->alignItemsVerticallyWithPadding(4);
    menu->setPosition(ccp(s.width - 50, s.height / 2 - 20));
    this->addChild(menu);

    m_plabel = NULL;
    m_eHorizAlign = kCCTextAlignmentLeft;
    m_eVertAlign = kCCVerticalTextAlignmentTop;

    this->updateAlignment();
}
CATabBarController::CATabBarController()
:m_nSelectedIndex(0)
,m_nLastSelectedIndex(0xffffffff)
,m_pTabBar(NULL)
,m_pContainer(NULL)
,m_bTabBarHidden(false)
,m_bscrollEnabled(false)
,m_pTabBarBackGroundImage(NULL)
,m_pTabBarSelectedBackGroundImage(NULL)
,m_pTabBarSelectedIndicatorImage(NULL)
,m_sTabBarBackGroundColor(CAColor_white)
,m_sTabBarSelectedBackGroundColor(CAColor_white)
,m_sTabBarSelectedIndicatorColor(CAColor_white)
,m_sTabBarTitleColor(CAColor_white)
,m_sTabBarSelectedTitleColor(ccc4(50, 193, 255, 255))
,m_bShowTabBarSelectedIndicator(false)
{
    m_pView->setColor(CAColor_clear);
    m_pView->setDisplayRange(false);
    
    this->setTabBarBackGroundImage(CAImage::create("source_material/tabBar_bg.png"));
    this->setTabBarSelectedBackGroundImage(CAImage::create("source_material/tabBar_selected_bg.png"));
    this->setTabBarSelectedIndicatorImage(CAImage::create("source_material/tabBar_selected_indicator.png"));
}
Exemple #25
0
//virtual 
void GameItemView::initView()
{
	int cardW = 200;
	int cardH = 200;
	setContentSize( CCSizeMake( cardW, cardH ));
	setAnchorPoint(ccp(0.5f,0.5f));

	CCLayerColor* bg = CCLayerColor::create(ccc4(25,25,25,155), cardW,cardH);
	bg->setAnchorPoint(ccp(0,0));
	addChild(bg, 1);

	m_lblName = CCLabelTTF::create();
	m_lblName->initWithString( "", "Arial", 24.0f  );
	m_lblName->setAnchorPoint(ccp(0.0f, 1.0f ) );
	m_lblName->setPositionY(cardH);
	addChild(m_lblName, 50);

	m_lblType = CCLabelTTF::create();
	m_lblType->initWithString( "", "Arial", 24.0f  );
	m_lblType->setAnchorPoint(ccp(0.0f, 1.0f ) );
	m_lblType->setPositionY(cardH - 50);
	addChild(m_lblType, 50);

}
Exemple #26
0
NS_CC_BEGIN

CAStepper::CAStepper()
: m_bAutoRepeat(true)
, m_bContinuous(true)
, m_bWraps(false)
, m_value(0)
, m_minimumValue(0)
, m_maximumValue(100)
, m_stepValue(0)
, m_pDecrementImageView(NULL)
, m_pIncrementImageView(NULL)
, m_pBackgroundImageView(NULL)
, m_pBackgroundSelectedImageView(NULL)
, m_actionType(ActionNone)
, m_bTouchEffect(false)
, m_pDividerImageView(NULL)
, m_pCAStepperOrientation(CAStepperOrientationHorizontal)
,m_cTintColor(ccc4(54, 195, 240, 255))
{
    memset(m_pBackgroundImage, 0x00, sizeof(m_pBackgroundImage));
    memset(m_pIncrementImage, 0x00, sizeof(m_pIncrementImage));
    memset(m_pDecrementImage, 0x00, sizeof(m_pDecrementImage));
}
//---------------------------------------------------------------------------
bool MC_GameOver::init()
{
	bool tRet = false;
    do 
    {
        CC_BREAK_IF(!CCLayer::init());

		//turn the color of backgrand white;
		CC_BREAK_IF(!CCLayerColor::initWithColor(ccc4(0, 0, 0, 125)));

		// Get window size and place the label upper. 
        CCSize tWinSize = CCDirector::sharedDirector()->getWinSize();

		CCMenuItemImage *tCloseItem = CCMenuItemImage::create("CloseNormal.png", "CloseSelected.png", this, menu_selector(MC_GameOver::menuCloseCallback));
		tCloseItem->setPosition(ccp(tWinSize.width - 20, 20));
		CCMenu* tMenu = CCMenu::create(tCloseItem, NULL);
		tMenu->setPosition(CCPointZero);
		this->addChild(tMenu, 0);

        tRet = true;
    } while (0);

    return tRet;
}
Exemple #28
0
void GameScene::showRateView()
{
    if (m_pRateLayer == NULL)
    {
        m_pRateLayer = LGLayerColor::create(ccc4(0, 0, 0, 0));
        m_pRateLayer->retain();
        m_pRateLayer->setTouchMode(kCCTouchesOneByOne);
        m_pRateLayer->setTouchEnabled(true);
        m_pRateLayer->setZOrder(3);

        CCSprite *pBg = CCSprite::create("rate_bg.png");
        pBg->setPosition(m_VisibleOrigin + m_VisibleSize / 2);
        m_pRateLayer->addChild(pBg);

        float bgW = pBg->getContentSize().width, bgH = pBg->getContentSize().height;
        CCMenuItemImage *pRate = LGMenuItemImage::create("rate_rate.png", NULL, this, menu_selector(GameScene::rateCallback));
        pRate->setPosition(ccp(pBg->getPositionX() - 0.2592593f * bgW, pBg->getPositionY() - 0.6566f * bgH));

        CCMenuItemImage *pLater = LGMenuItemImage::create("rate_later.png", NULL, this, menu_selector(GameScene::laterCallback));
        pLater->setPosition(ccp(pBg->getPositionX() + 0.2592593f * bgW, pRate->getPositionY()));

        CCMenu *pMenu = CCMenu::create(pRate, pLater, NULL);
        pMenu->setAnchorPoint(CCPointZero);
        pMenu->setPosition(CCPointZero);
        m_pRateLayer->addChild(pMenu);
    }

    if (m_pRateLayer && m_pRateLayer->getParent() == NULL)
    {
        getParent()->addChild(m_pRateLayer);
        CC_SAFE_RELEASE_NULL(m_CurrentLayer);
        m_CurrentLayer = m_pRateLayer;
        m_CurrentLayer->retain();
        onShowOverlay(true);
    }
}
// on "init" you need to initialize your instance
bool BGLayer::init()
{
    //////////////////////////////
    // 1. super init first
	if( !CCLayerColor::initWithColor(ccc4(255, 255, 255, 255)) ) 
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

	this->setColor(Color3B(80, 80, 80));
	

	bigLabel = Label::createWithTTF("FASTER", "fonts/MAVERICK.ttf", 144);
	bigLabel->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2));
    this->addChild(bigLabel, 1); 
    //bigLabel->runAction(RepeatForever::create(Sequence::create(CCScaleTo::create(0.5f, 1.3f, 1.0f), CCScaleTo::create(0.5f, 1.0f, 1.3f), NULL)));
	bigLabel->runAction(RepeatForever::create(Sequence::create(CCMoveBy::create(0.05f, Vec2(-30.0f, 0.0f)), CCMoveBy::create(0.05f, Vec2(30.0f, 0.0f)), CCMoveBy::create(0.05f, Vec2(0.0f, 0.0f)), 
															   CCMoveBy::create(0.05f, Vec2(0.0f, 30.0f)), CCMoveBy::create(0.05f, Vec2(0.0f, -30.0f)), CCMoveBy::create(0.05f, Vec2(0.0f, 0.0f)), NULL)));														  
    
    return true;
}
Exemple #30
0
bool CGradientView::init()
{
	return initWithColor(ccc4(0, 0, 0, 255), ccc4(0, 0, 0, 255));
}