Exemple #1
0
void MainLayer::createSpecRecomend()
{
	if (!_hideNode->isVisible() || _pageView->getCurPageIndex() != MAIN_PAGE || !_isUseSpec)
		return;

	auto rt = RenderTexture::create(_pageView->getContentSize().width,
		_pageView->getContentSize().height,
		Texture2D::PixelFormat::RGBA8888,
		GL_DEPTH24_STENCIL8);
	rt->beginWithClear(0, 0, 0, 0, 0);
	_pageView->getPage(MAIN_PAGE)->visit(_director->getRenderer(), _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW), true);
	rt->end();
	rt->getSprite()->setScaleY(-1);

	auto sprite = dynamic_cast<Sprite*>(LsTools::seekNodeByName(_rootNode, formatStr("dy_%d", MAIN_PAGE)));
	sprite->setTexture(rt->getSprite()->getTexture());

	auto pane1 = LsTools::seekNodeByName(_pageView, "Panel_0");
	auto img3 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "3"));
	auto img0 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "0"));
	auto img2 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "2"));
	auto img1 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "1"));

	Rect rect(img1->getLeftBoundary(), img1->getBottomBoundary(),
		img3->getRightBoundary() - img1->getLeftBoundary(),
		img2->getContentSize().height);

	sprite->setTextureRect(Rect(rect.origin.x, rect.origin.y, rect.size.width, 300));
	float bot = img2->getBottomBoundary() - (sprite->getTextureRect().getMaxY() - sprite->getTextureRect().getMinY()) / 2 - 5;
}
Exemple #2
0
void MainLayer::createSpec(int index)
{
	//return;
	if (!_hideNode->isVisible() || !_isUseSpec)
		return;
	_pageView->setPositionX(-MY_SCREEN.width * index);
	auto rt = RenderTexture::create(_pageView->getContentSize().width,
		_pageView->getContentSize().height,
		Texture2D::PixelFormat::RGBA8888,
		GL_DEPTH24_STENCIL8);
	rt->beginWithClear(0, 0, 0, 0, 0);
	_pageView->getPage(index)->visit(_director->getRenderer(), _director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW), true);
	rt->end();
	rt->getSprite()->setScaleY(-1);
	// 	_renderPageViewTex->saveToFile("pageview.png");

	auto sprite = dynamic_cast<Sprite*>(LsTools::seekNodeByName(_rootNode, formatStr("dy_%d", index)));
	sprite->setTexture(rt->getSprite()->getTexture());
	//sprite->setTextureRect(rt->getSprite()->getTextureRect());

	if (index == 0)//main page
	{
		auto pane1 = LsTools::seekNodeByName(_pageView, "Panel_0");
		auto img3 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "3"));
		auto img0 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "0"));
		auto img2 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "2"));
		auto img1 = (ui::ImageView*)(LsTools::seekNodeByName(pane1, "1"));

		Rect rect(img1->getLeftBoundary(), img1->getBottomBoundary(),
			img3->getRightBoundary() - img1->getLeftBoundary(),
			img2->getContentSize().height);

		sprite->setTextureRect(Rect(rect.origin.x, rect.origin.y, rect.size.width, 300));
		float bot = img2->getBottomBoundary() - (sprite->getTextureRect().getMaxY() - sprite->getTextureRect().getMinY()) / 2 - 5;
		//sprite->setPosition(_pageView->getContentSize().width / 2, bot);
	}
	else/* if (curPage == 1)*///game category page
	{
		auto pane2 = LsTools::seekNodeByName(_pageView, "Panel_1");
		auto img0 = (ui::ImageView*)(LsTools::seekNodeByName(pane2, "0"));
		auto img5 = (ui::ImageView*)(LsTools::seekNodeByName(pane2, "5"));

		Rect rect(img0->getLeftBoundary(), img0->getBottomBoundary(),
			img5->getRightBoundary() - img0->getLeftBoundary(),
			img5->getContentSize().height);

		sprite->setTextureRect(Rect(rect.origin.x, rect.origin.y, rect.size.width, 300));
		float bot = img0->getBottomBoundary() - (sprite->getTextureRect().getMaxY() - sprite->getTextureRect().getMinY()) / 2 - 5;
		//sprite->setPosition(_pageView->getContentSize().width / 2, bot);
	}
}
Exemple #3
0
float Widget::getTopBoundary() const
{
    return getBottomBoundary() + _contentSize.height;
}