コード例 #1
0
ファイル: BaseScene.cpp プロジェクト: ezibyte/EziSocialDemo
void BaseScene::buildScene()
{
    // Add the background.
    
    this->setKeypadEnabled(true);
    
    CCLayerColor* bgColorLayer = CCLayerColor::create(ccc4(41, 69, 66, 255), AppDelegate::SCREEN_WIDTH, AppDelegate::SCREEN_HEIGHT);
    this->addChild(bgColorLayer);
    
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(PLIST_FILE(kRESOURCE_BG));
    
    CCSprite* backgroundSprite = CCSprite::createWithSpriteFrameName("background");
    this->addChild(backgroundSprite);
    PlaceNode(backgroundSprite, 0.5, 0.5)
 
    CCSpriteBatchNode* commonBatchNode = CCSpriteBatchNode::create(PNG_FILE(kRESOURCE_COMMON));
    this->addChild(commonBatchNode);
    
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(PLIST_FILE(kRESOURCE_COMMON));
    
    
    // Create tile menu
    BaseScene::buildTileMenuSkelton();
    this->addChild(_tileMenu);
    
    // Create Navigation Buttons
    this->addNavigationButtons();
    
    if (AppDelegate::SCREEN_HEIGHT > 640.0f)
    {
        //EziAdMobObject::sharedObject()->loadBannerAd();
    }
    
}
コード例 #2
0
ファイル: BaseScene.cpp プロジェクト: ezibyte/EziSocialDemo
void BaseScene::buildTileMenuSkelton()
{
    _tileMenu = NULL;
    _tileMenu = CCMenu::create();
    _tileMenu->setContentSize(CCSizeMake(AppDelegate::SCREEN_WIDTH, AppDelegate::SCREEN_HEIGHT));
    PlaceNode(_tileMenu, 0.0, 0.0);
}
コード例 #3
0
ファイル: lwf_cocos2dx_factory.cpp プロジェクト: Bruke/lwf
void LWFRendererFactory::EndRender(LWF *lwf)
{
	if (!m_masks.empty()) {
		for (int i = ++m_maskNo; i < m_masks.size(); ++i) {
			auto& children = m_masks[i]->getChildren();
			for (auto& node : children)
				PlaceNode(m_node, node);
			m_masks[i]->removeFromParentAndCleanup(true);
		}
		m_masks.resize(m_maskNo);
	}
}
コード例 #4
0
ファイル: BaseScene.cpp プロジェクト: ezibyte/EziSocialDemo
void BaseScene::addTipBoard(const char* tip)
{
    CCSprite* tipBoard = CCSprite::createWithSpriteFrameName("tip_board");
    tipBoard->setAnchorPoint(ccp(0.0f, 1.0f));
    
    //tipBoard->cocos2d::CCNode::setPosition(SCALED_VALUE(12.0f), SCALED_VALUE(368.0f));
    PlaceNode(tipBoard, 0.02, 0.764);
    this->addChild(tipBoard);
    
    CCLabelTTF* tipLabel = CCLabelTTF::create(tip, "Arial", SCALED_VALUE(20.0f));
    tipLabel->setColor(ccc3(33, 33, 33));
    tipLabel->setAnchorPoint(ccp(0.5f, 1.0f));
    tipLabel->setDimensions(CCSizeMake(tipBoard->getContentSize().width * 0.8, tipBoard->getContentSize().height * 0.8));
    
    float py = 0.0f;
    py = tipBoard->getPositionY();
    py = py - SCALED_VALUE(127.0f);
    tipLabel->setPositionY(py);
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    tipBoard->setScaleY(1.20f);
    
    if (AppDelegate::SCREEN_HEIGHT > 400.0f)
    {
        tipLabel->setPositionY(py + SCALED_VALUE(10.0f));
    }
    else
    {
        tipLabel->setPositionY(py - SCALED_VALUE(5.0f));
    }
    
    
#else
    //PlaceNode(tipLabel, 0.04, 0.55);
#endif
    
    //tipLabel->setPositionY(py);
    
    float pX = tipBoard->getPositionX() + tipBoard->getContentSize().width/2;
    tipLabel->setPositionX(pX);
    
    this->addChild(tipLabel);
}
コード例 #5
0
ファイル: lwf_cocos2dx_factory.cpp プロジェクト: Bruke/lwf
bool LWFRendererFactory::Render(class LWF *lwf, Node *node,
	BlendEquationProtocol *be, int renderingIndex, bool visible,
	BlendFunc *baseBlendFunc)
{
	m_renderingIndex = renderingIndex;

	node->setVisible(visible);
	if (!visible)
		return false;

	Node *target;
	switch (m_maskMode) {
	case Format::BLEND_MODE_ERASE:
	case Format::BLEND_MODE_MASK:
	case Format::BLEND_MODE_LAYER:
		{
			LWFMask *mask;
			if (m_lastMaskMode != m_maskMode) {
				++m_maskNo;
				if (m_masks.size() > m_maskNo) {
					mask = m_masks[m_maskNo];
				} else {
					mask = LWFMask::create();
					m_masks.push_back(mask);
				}
				PlaceNode(m_node, mask);

				LWFMask *layer = nullptr;
				if (m_lastMaskMode == Format::BLEND_MODE_LAYER &&
						(m_maskMode == Format::BLEND_MODE_ERASE ||
							m_maskMode == Format::BLEND_MODE_MASK) &&
						m_maskNo > 0) {
					layer = m_masks[m_maskNo - 1];
					if (layer)
						layer->setLocalZOrder(INT_MAX);
					PlaceNode(mask, layer);
				}

				if (layer && mask) {
					switch (m_maskMode) {
					case Format::BLEND_MODE_ERASE:
					case Format::BLEND_MODE_MASK:
						switch (m_maskMode) {
						case Format::BLEND_MODE_ERASE:
							layer->setBlendFunc(
								{GL_ONE_MINUS_DST_ALPHA, GL_ZERO});
							break;
						case Format::BLEND_MODE_MASK:
							layer->setBlendFunc(
								{GL_DST_ALPHA, GL_ZERO});
							break;
						}
						BlendFunc blendFunc = {GL_ONE, GL_ZERO};
						GetBlendFunc(blendFunc, m_blendMode);
						mask->setBlendFunc(blendFunc);
						break;
					}
				}

				m_lastMaskMode = m_maskMode;
			} else {
				mask = m_masks[m_maskNo];
			}
			if (mask)
				mask->setLocalZOrder(m_renderingIndex + 1);
			target = mask;

		}
		break;

	default:
		target = m_node;
		break;
	}

	PlaceNode(target, node);

	node->setLocalZOrder(renderingIndex);

	BlendProtocol *p = dynamic_cast<BlendProtocol *>(node);
	if (p) {
		BlendFunc blendFunc =
			baseBlendFunc ? *baseBlendFunc : p->getBlendFunc();
		GetBlendFunc(blendFunc, m_blendMode);
		p->setBlendFunc(blendFunc);
	}

	BlendEquationProtocol *ep = dynamic_cast<BlendEquationProtocol *>(node);
	if (ep)
		ep->setBlendEquation(m_blendMode);

	return true;
}
コード例 #6
0
ファイル: BaseScene.cpp プロジェクト: ezibyte/EziSocialDemo
void BaseScene::buildHeader(int highlightIndex, const char* title, const char* description)
{
    _currentMenuIndex = highlightIndex;
    
    CCMenuItemImage* homeButton = CCMenuItemImage::create();
    homeButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_nrl"));
    homeButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
    homeButton->setTarget(this, menu_selector(BaseScene::loadHomeScene));
    homeButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    CCMenuItemImage* fbActionButton = CCMenuItemImage::create();
    fbActionButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_nrl"));
    fbActionButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_prd"));
    fbActionButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_dis"));
    fbActionButton->setTarget(this, menu_selector(BaseScene::loadFBActionScene));
    fbActionButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    if (EziSocialObject::sharedObject()->isFacebookSessionActive() == false)
    {
        fbActionButton->setEnabled(false);
    }
    
    CCMenuItemImage* helpButton = CCMenuItemImage::create();
    helpButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_nrl"));
    helpButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
    helpButton->setTarget(this, menu_selector(BaseScene::loadHelpScene));
    
    helpButton->setAnchorPoint(ccp(1.0f, 1.0f));
    
    switch (highlightIndex)
    {
        case 0:
            homeButton->setEnabled(false);
            break;
            
        case 1:
            fbActionButton->setEnabled(false);
            break;
            
        case 2:
            helpButton->setEnabled(false);
            break;
            
        default:
            break;
    }
    
    
    CCMenu* homeMenu = CCMenu::create(homeButton, fbActionButton, helpButton, NULL);
    homeMenu->alignItemsHorizontally();
    
    this->addChild(homeMenu);
    PlaceNode(homeMenu, 0.88, 0.98);
    
    // Add a line.
    CCLayerColor* lineLayer = CCLayerColor::create(ccc4(204, 204, 204, 204),
                                                   CCDirector::sharedDirector()->getVisibleSize().width,
                                                   1.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    
    this->addChild(lineLayer);
    PlaceNode(lineLayer, 0.0, 0.8);
    lineLayer->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height - (7 * AppDelegate::SCREEN_SCALE_FACTOR));
    
    // Add Title
    CCLabelTTF* titleLabel = CCLabelTTF::create(title, "Arial", 50.0 * AppDelegate::SCREEN_SCALE_FACTOR);
    this->addChild(titleLabel);
    titleLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    //PlaceNode(titleLabel, 0.02, 0.98);
    
    CCLabelTTF* descriptionLabel = CCLabelTTF::create(description,
                                                      "Arial", SCALED_VALUE(22.0f));
    this->addChild(descriptionLabel);
    descriptionLabel->setAnchorPoint(ccp(0.0f, 0.0f));
    PlaceNode(descriptionLabel, 0.02, 0.98);
    descriptionLabel->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height);
    descriptionLabel->setColor(ccc3(204, 204, 204));
    
    titleLabel->cocos2d::CCNode::setPosition(descriptionLabel->getPositionX(),
                                             descriptionLabel->getPositionY() + descriptionLabel->getContentSize().height - 2.0f);
    
}